Update rules

WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by rule Error Prone/AvoidEnumAsIdentifier, please use @Name instead
WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by rule Error Prone/AvoidAssertAsIdentifier, please use @Name instead
WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by rule Error Prone/ProperLogger, please use @Name instead
WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by rule Error Prone/JumbledIncrementer, please use @Name instead
WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by rule Error Prone/AvoidLosingExceptionInformation, please use @Name instead
WARNING: Use of deprecated attribute 'VariableDeclaratorId/@Image' by rule Error Prone/EmptyCatchBlock, please use @Name instead
This commit is contained in:
Clément Fournier
2020-04-17 20:31:09 +02:00
parent f3db39641a
commit e2ec5450ff
3 changed files with 17 additions and 17 deletions

View File

@ -1236,7 +1236,7 @@ Fields, formal arguments, or local variable names that are too long can make the
<property name="xpath">
<value>
<![CDATA[
//VariableDeclaratorId[string-length(@Image) > $minimum]
//VariableDeclaratorId[string-length(@Name) > $minimum]
]]>
</value>
</property>
@ -1704,7 +1704,7 @@ Fields, local variables, or parameter names that are very short are not helpful
<property name="xpath">
<value>
<![CDATA[
//VariableDeclaratorId[string-length(@Image) < $minimum]
//VariableDeclaratorId[string-length(@Name) < $minimum]
(: ForStatement :)
[not(../../..[self::ForInit])]
(: Foreach statement :)

View File

@ -140,7 +140,7 @@ Use of the term 'assert' will conflict with newer versions of Java since it is a
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>//VariableDeclaratorId[@Image='assert']</value>
<value>//VariableDeclaratorId[@Name='assert']</value>
</property>
</properties>
<example>
@ -347,7 +347,7 @@ Use of the term 'enum' will conflict with newer versions of Java since it is a r
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>//VariableDeclaratorId[@Image='enum']</value>
<value>//VariableDeclaratorId[@Name='enum']</value>
</property>
</properties>
<example>
@ -546,15 +546,15 @@ only add to code size. Either remove the invocation, or use the return result.
<![CDATA[
//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
[
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getMessage')
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
or
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getLocalizedMessage')
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
or
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getCause')
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
or
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.getStackTrace')
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
or
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Image, '.toString')
@Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
]
]]>
</value>
@ -1487,7 +1487,7 @@ or reported.
[FormalParameter/Type/ReferenceType
/ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
]
[FormalParameter/VariableDeclaratorId[not(matches(@Image, $allowExceptionNameRegex))]]
[FormalParameter/VariableDeclaratorId[not(matches(@Name, $allowExceptionNameRegex))]]
]]>
</value>
</property>
@ -2147,7 +2147,7 @@ Avoid jumbled loop incrementers - its usually a mistake, and is confusing even i
[
ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
=
ancestor::ForStatement/ForInit//VariableDeclaratorId/@Image
ancestor::ForStatement/ForInit//VariableDeclaratorId/@Name
]
]]>
</value>
@ -2702,8 +2702,8 @@ with the restriction that the logger needs to be passed into the constructor.
(: check modifiers :)
(@Private = false() or @Final = false())
(: check logger name :)
or (@Static and VariableDeclarator/VariableDeclaratorId[@Image != $staticLoggerName])
or (@Static = false() and VariableDeclarator/VariableDeclaratorId[@Image != $loggerName])
or (@Static and VariableDeclarator/VariableDeclaratorId[@Name != $staticLoggerName])
or (@Static = false() and VariableDeclarator/VariableDeclaratorId[@Name != $loggerName])
(: check logger argument type matches class or enum name :)
or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::ClassOrInterfaceDeclaration/@SimpleName]
@ -2717,7 +2717,7 @@ with the restriction that the logger needs to be passed into the constructor.
ancestor::ClassOrInterfaceBody//ConstructorDeclaration//StatementExpression
[PrimaryExpression[PrimaryPrefix[@ThisModifier]]/PrimarySuffix[@Image=$loggerName]]
[AssignmentOperator[@Image = '=']]
[Expression/PrimaryExpression/PrimaryPrefix/Name[@Image = ancestor::ConstructorDeclaration//FormalParameter/VariableDeclaratorId/@Image]]
[Expression/PrimaryExpression/PrimaryPrefix/Name[@Image = ancestor::ConstructorDeclaration//FormalParameter/VariableDeclaratorId/@Name]]
[not(.//AllocationExpression)]
)
]

View File

@ -878,14 +878,14 @@ You must use new ArrayList<>(Arrays.asList(...)) if that is inconvenient for you
@Image="ArrayList"
]
)=1
]/@Image
]/@Name
]
and
PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name
[
@Image = ancestor::MethodDeclaration[1]//LocalVariableDeclaration/VariableDeclarator/VariableDeclaratorId[@ArrayType=true()]/@Image
@Image = ancestor::MethodDeclaration[1]//LocalVariableDeclaration/VariableDeclarator/VariableDeclaratorId[@ArrayType=true()]/@Name
or
@Image = ancestor::MethodDeclaration[1]//FormalParameter/VariableDeclaratorId/@Image
@Image = ancestor::MethodDeclaration[1]//FormalParameter/VariableDeclaratorId/@Name
]
/../..[count(.//PrimarySuffix)
=1]/PrimarySuffix/Expression/PrimaryExpression/PrimaryPrefix