|
3 | 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4 | 4 | xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
|
5 | 5 |
|
6 |
| - <description>This ruleset was created from PMD.rul</description> |
| 6 | + <description>Check for flaws in Glide's codebase.</description> |
7 | 7 |
|
8 | 8 | <rule ref="rulesets/java/basic.xml">
|
9 | 9 | <exclude name="AvoidBranchingStatementAsLastInLoop"/>
|
10 | 10 | </rule>
|
11 | 11 | <rule ref="rulesets/java/braces.xml"/>
|
12 |
| - <rule ref="rulesets/java/strings.xml"> |
13 |
| - <!-- TODO: This warns about annotations, apparently fixed in a later version. --> |
14 |
| - <exclude name="AvoidDuplicateLiterals"/> |
| 12 | + <rule ref="rulesets/java/strings.xml"/> |
| 13 | + <rule ref="rulesets/java/strings.xml/AvoidDuplicateLiterals"> |
| 14 | + <properties> |
| 15 | + <property name="skipAnnotations" value="true" /> |
| 16 | + </properties> |
15 | 17 | </rule>
|
16 | 18 | <rule ref="rulesets/java/unusedcode.xml"/>
|
17 | 19 |
|
|
28 | 30 | <exclude name="GodClass"/>
|
29 | 31 | </rule>
|
30 | 32 |
|
| 33 | + <rule ref="rulesets/java/design.xml/AccessorMethodGeneration" |
| 34 | + message="Avoid autogenerated methods to access private fields and methods of inner / outer classes. |
| 35 | + Use @Synthetic to flag members made more visible than necessary to prevent accessors."> |
| 36 | + <properties> |
| 37 | + <!-- Ignore references to `private static final * * = <literal>` |
| 38 | + Suppress via XPath: current node (access that generates the accessor) is . |
| 39 | + Check if there exists a FieldDeclaration (private static final) |
| 40 | + which has a VariableInitializer with a Literal |
| 41 | + and the name (@Image) of the declaration is the same as the accessed member. |
| 42 | + TODO calculated constants are false positive https://github.com/pmd/pmd/issues/808 |
| 43 | + --> |
| 44 | + <property name="violationSuppressXPath" value=" |
| 45 | + .[@Image = |
| 46 | + //FieldDeclaration[@Private = 'true' and @Static='true' and @Final='true'] |
| 47 | + /VariableDeclarator[ |
| 48 | + VariableInitializer/Expression/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal |
| 49 | + ]/VariableDeclaratorId/@Image |
| 50 | + ]" /> |
| 51 | + </properties> |
| 52 | + </rule> |
| 53 | + |
31 | 54 | <rule ref="rulesets/java/empty.xml/EmptyCatchBlock" message="Commented blocks are ok">
|
32 | 55 | <properties>
|
33 | 56 | <property name="allowCommentedBlocks" value="true"/>
|
34 | 57 | </properties>
|
35 | 58 | </rule>
|
36 | 59 |
|
37 |
| - |
38 |
| - <!--Overrides default check to avoid violation when @Synthetic annotation is present--> |
39 |
| - <rule ref="rulesets/java/design.xml/UncommentedEmptyConstructor" |
40 |
| - message="Document empty constructor"> |
41 |
| - |
| 60 | + <!-- Configures check to avoid violation when @Synthetic annotation is present. --> |
| 61 | + <rule ref="rulesets/java/design.xml/UncommentedEmptyConstructor"> |
42 | 62 | <properties>
|
43 |
| - <property name="xpath"> |
44 |
| - <value> |
45 |
| - <![CDATA[ |
46 |
| -//ConstructorDeclaration[@Private='false'][count(BlockStatement) = 0 and |
47 |
| -($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false' |
48 |
| - and not(../Annotation/MarkerAnnotation/Name[@Image='Synthetic'])] |
49 |
| - ]]> |
50 |
| - </value> |
51 |
| - </property> |
52 |
| - |
| 63 | + <property name="violationSuppressXPath" |
| 64 | + value="../Annotation/MarkerAnnotation/Name[@Image='Synthetic']" /> |
53 | 65 | </properties>
|
54 |
| - |
55 | 66 | </rule>
|
56 | 67 |
|
57 |
| - |
58 | 68 | </ruleset>
|
0 commit comments