From c0d0fd3fbe01c876cdb1ad643cb7dc59756438b7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 8 Dec 2019 12:31:29 +0100 Subject: [PATCH] [java] AvoidLiteralsInIfCondition: report Literal rather than IfCondition If the IfCondition spans multiple lines, it easier to spot the literal, if the violation is reported on the correct line where the literal is located. --- pmd-java/src/main/resources/category/java/errorprone.xml | 6 ++---- .../java/rule/errorprone/xml/AvoidLiteralsInIfCondition.xml | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 2a28cf8ea0..2771f6dd59 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -470,18 +470,16 @@ More exceptions can be defined with the property "ignoreMagicNumbers". diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidLiteralsInIfCondition.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidLiteralsInIfCondition.xml index 29872b3c96..e9a9f4dfba 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidLiteralsInIfCondition.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/AvoidLiteralsInIfCondition.xml @@ -93,8 +93,8 @@ public class Foo { #2140 [java] AvoidLiteralsInIfCondition: false negative for expressions - 3 - 3,4,5 + 4 + 3,3,4,5