From a96cd5fd9ed9163101591eb83d965b425cbe211b Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 1 Apr 2017 11:44:39 +0300 Subject: [PATCH 1/6] FindBugs exclude filter for StringUtils Exclude ES_COMPARING_PARAMETER_STRING_WITH_EQ FindBugs warnings from StringUtils methods compare(String, String, boolean) and compareIgnoreCase(String, String, boolean). The usages of the == operator seem to be intentional optimizations similar to the usage in indexOfDifference. If this reasoning is ever overruled, this suppression should be removed. --- findbugs-exclude-filter.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index def3ec8841e..f7623dfd3cf 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -58,7 +58,11 @@ - + + + + + From b4fa061c2991c3dc9832570b80ef55ce125b533d Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 1 Apr 2017 12:18:53 +0300 Subject: [PATCH 2/6] Exclude SF_SWITCH_NO_DEFAULT on FastDateParser FastDateParser#simpleQuote uses a switch case that actually has a default branch in it, but doesn't use break statements. SF_SWITCH_NO_DEFAULT unfortunately cannot recognize this pattern, and leave us with no choice but to suppress it. --- findbugs-exclude-filter.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index f7623dfd3cf..772052acebe 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -139,9 +139,14 @@ + - + + + + From 44d3dddcd1c6f3161395489027b6963fa8e0f071 Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 1 Apr 2017 12:38:54 +0300 Subject: [PATCH 3/6] Exclude SF_SWITCH_FALLTHROUGH on FastDatePrinter FastDatePrinter#appendFullDigits uses a switch statement that intentionally falls through the cases. This patch adds a FindBugs suppression for it. --- findbugs-exclude-filter.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index 772052acebe..edc6eadea13 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -150,6 +150,13 @@ + + + + + + + From 60e087c652f080d7826d1f244f1e6e9adc708e6a Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 1 Apr 2017 12:18:53 +0300 Subject: [PATCH 4/6] Exclude SF_SWITCH_NO_DEFAULT on FastDatePrinter FastDatePrinter#appendFullDigits uses a switch case without break statements. SF_SWITCH_NO_DEFAULT unfortunately cannot recognize this pattern, and leave us with no choice but to suppress it. --- findbugs-exclude-filter.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index edc6eadea13..23dddbdf75b 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -150,6 +150,14 @@ + + + + + + + From 3525f756d087e3de370bc069fca96b7ab298b8c3 Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 1 Apr 2017 12:16:52 +0300 Subject: [PATCH 5/6] Add a default case to switch to appease FindBugs --- src/main/java/org/apache/commons/lang3/time/FastDateParser.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index e27acf4c427..9cf1a1cb2ba 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -863,6 +863,8 @@ private static class TzInfo { case 5: // offset 5 starts additional names, probably standard time tzInfo = standard; break; + default: + break; } if (zoneNames[i] != null) { final String key = zoneNames[i].toLowerCase(locale); From ea0b56f409699dbc5e983892d73315ed7139e452 Mon Sep 17 00:00:00 2001 From: Allon Mureinik Date: Sat, 1 Apr 2017 12:49:24 +0300 Subject: [PATCH 6/6] Add FindBugs to Travis CI This patch copies the FindBugs configuration in pom.xml from the reporting section to the build section so findbugs can be used as part of the build process (by using the maven goal findbugs:check). It then adds this goal to the Travis CI build so that FindBugs becomes part of the CI, and new patches would be prevented from introducing new FindBugs errors. --- .travis.yml | 2 +- pom.xml | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e81e8cdfed2..f0a6c49c642 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jdk: - oraclejdk8 script: - - mvn test apache-rat:check clirr:check checkstyle:check javadoc:javadoc -B + - mvn test apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc -B after_success: - mvn clean cobertura:cobertura coveralls:report diff --git a/pom.xml b/pom.xml index 90e73c55e76..40afe3e8b35 100644 --- a/pom.xml +++ b/pom.xml @@ -660,6 +660,15 @@ false + + org.codehaus.mojo + findbugs-maven-plugin + + ${commons.findbugs.version} + + ${basedir}/findbugs-exclude-filter.xml + +