diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 1b2450a8e2..3d9505e6a4 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -169,6 +169,7 @@ All existing rules have been updated to reflect these changes. If you have custo * java-comments * [#536](https://github.com/pmd/pmd/issues/536): \[java] CommentDefaultAccessModifierRule ignores constructors * java-controversial + * [#388](https://github.com/pmd/pmd/issues/388): \[java] controversial.AvoidLiteralsInIfCondition 0.0 false positive * [#408](https://github.com/pmd/pmd/issues/408): \[java] DFA not analyzing asserts * [#537](https://github.com/pmd/pmd/issues/537): \[java] UnnecessaryParentheses fails to detect obvious scenario * java-design @@ -288,3 +289,4 @@ All existing rules have been updated to reflect these changes. If you have custo * [#583](https://github.com/pmd/pmd/pull/583): \[java] Documentation about writing metrics - [Clément Fournier](https://github.com/oowekyala) * [#585](https://github.com/pmd/pmd/pull/585): \[java] Moved NcssCountRule to codesize.xml - [Clément Fournier](https://github.com/oowekyala) * [#588](https://github.com/pmd/pmd/pull/588): \[java] XPath function to compute metrics - [Clément Fournier](https://github.com/oowekyala) +* [#598](https://github.com/pmd/pmd/pull/598): \[java] Fix #388: controversial.AvoidLiteralsInIfCondition 0.0 false positive - [Clément Fournier](https://github.com/oowekyala) diff --git a/pmd-java/src/main/resources/rulesets/java/controversial.xml b/pmd-java/src/main/resources/rulesets/java/controversial.xml index 779217c9f0..5c59d8f486 100644 --- a/pmd-java/src/main/resources/rulesets/java/controversial.xml +++ b/pmd-java/src/main/resources/rulesets/java/controversial.xml @@ -681,7 +681,7 @@ More exceptions can be defined with the property "ignoreMagicNumbers". //IfStatement/Expression/*/PrimaryExpression/PrimaryPrefix/Literal [not(NullLiteral)] [not(BooleanLiteral)] -[empty(index-of(tokenize($ignoreMagicNumbers, ','), @Image))] +[empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))] ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/controversial/xml/AvoidLiteralsInIfCondition.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/controversial/xml/AvoidLiteralsInIfCondition.xml index 57a5ab6798..9da329bc6d 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/controversial/xml/AvoidLiteralsInIfCondition.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/controversial/xml/AvoidLiteralsInIfCondition.xml @@ -74,4 +74,19 @@ public class Foo { } ]]> + + #388 False positive due to space in property list + 0 + + + +