#1422 UselessQualifiedThis: False positive with Java 8 Function

This commit is contained in:
Andreas Dangel
2015-11-20 10:05:49 +01:00
parent 4a0853060f
commit 988931c43d
3 changed files with 27 additions and 4 deletions

View File

@ -297,10 +297,12 @@ public class Foo {
<property name="xpath">
<value>
<![CDATA[
//PrimaryExpression[
PrimaryPrefix/Name[@Image] and PrimarySuffix[@Arguments='false']
and ancestor::ClassOrInterfaceBodyDeclaration[1][@AnonymousInnerClass='false']
]/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image]
//PrimaryExpression
[PrimaryPrefix/Name[@Image]]
[PrimarySuffix[@Arguments='false']]
[not(PrimarySuffix/MemberSelector)]
[ancestor::ClassOrInterfaceBodyDeclaration[1][@AnonymousInnerClass='false']]
/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image]
]]>
</value>
</property>

View File

@ -130,4 +130,23 @@ public class Foo {
</code>
</test-code>
<test-code>
<description>#1422 UselessQualifiedThis: False positive with Java 8 Function</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class ApiExceptionCtrlAdvice {
public final List<ApiError> handleApiAggregateException(final ApiAggregateException e) {
return e.getCauses().stream().map(
ApiExceptionCtrlAdvice::toApiError
).collect(Collectors.toList());
}
private static ApiError toApiError(final Throwable e) {
return new ApiError()
.withException(e.getClass().getName())
.withCause(Optional.ofNullable(e.getCause()).map(Throwable::getClass).map(Class::getName).orElse(EMPTY))
.withMessage(Optional.ofNullable(e.getMessage()).orElse(EMPTY));
}
}
]]></code>
</test-code>
</test-data>