Merge branch 'pr-556'

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-08-16 15:18:00 -03:00
3 changed files with 39 additions and 2 deletions

View File

@ -1413,6 +1413,7 @@ public void doSomething() {
since="3.4"
message="Document empty constructor"
class="net.sourceforge.pmd.lang.rule.XPathRule"
typeResolution="true"
externalInfoUrl="${pmd.website.baseurl}/rules/java/design.html#UncommentedEmptyConstructor">
<description>
Uncommented Empty Constructor finds instances where a constructor does not
@ -1425,8 +1426,10 @@ and unintentional empty constructors.
<property name="xpath">
<value>
<![CDATA[
//ConstructorDeclaration[@Private='false'][count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false']
]]>
//ConstructorDeclaration[@Private='false']
[count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false']
[not(../Annotation/MarkerAnnotation/Name[typeof(@Image, 'javax.inject.Inject', 'Inject')])]
]]>
</value>
</property>
<property name="ignoreExplicitConstructorInvocation" type="Boolean" description="Ignore explicit constructor invocation when deciding whether constructor is empty or not" value="false"/>

View File

@ -170,4 +170,32 @@ public class WebAgent {
}
]]></code>
</test-code>
<test-code>
<description>#357 UncommentedEmptyConstructor consider annotations on Constructor</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import javax.inject.Inject;
public class MyClass {
@Inject MyClass() {
}
}
]]>
</code>
</test-code>
<test-code>
<description>#357 UncommentedEmptyConstructor consider fully qualified annotations on Constructor</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class MyClass {
@javax.inject.Inject MyClass() {
}
}
]]>
</code>
</test-code>
</test-data>