You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2017/04/19 16:25:36 UTC

[1/6] [lang] Exclude SF_SWITCH_NO_DEFAULT on FastDatePrinter

Repository: commons-lang
Updated Branches:
  refs/heads/master 5a5244609 -> 9ceaaeb65


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.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/8069e1c1
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/8069e1c1
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/8069e1c1

Branch: refs/heads/master
Commit: 8069e1c1ce7ec864c7bab2eae880742fac02376b
Parents: 4d343cc
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:18:53 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8069e1c1/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index edc6ead..23dddbd 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -150,6 +150,14 @@
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
 
+  <!-- Reason: FindBugs cannot correctly recognize default branches in switch statements without break statements.
+   See, e.g., the report at https://sourceforge.net/p/findbugs/bugs/1298 -->
+  <Match>
+    <Class name="org.apache.commons.lang3.time.FastDatePrinter"/>
+    <Method name="appendFullDigits" params="java.lang.Appendable, int, int"/>
+    <Bug pattern="SF_SWITCH_NO_DEFAULT" />
+  </Match>
+
   <!-- Reason: The fallthrough on the swich stateme is intentional -->
   <Match>
     <Class name="org.apache.commons.lang3.time.FastDatePrinter"/>


[6/6] [lang] Add FindBugs to Travis CI (closes #262)

Posted by pa...@apache.org.
Add FindBugs to Travis CI (closes #262)

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.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9ceaaeb6
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9ceaaeb6
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9ceaaeb6

Branch: refs/heads/master
Commit: 9ceaaeb6566c78b25da0ae8181964b13f09204a8
Parents: 9f7d03f
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:49:24 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:25:04 2017 +0200

----------------------------------------------------------------------
 .travis.yml | 2 +-
 pom.xml     | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9ceaaeb6/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index e81e8cd..f0a6c49 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

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9ceaaeb6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8bea60c..bca6df4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -660,6 +660,15 @@
           <enableRulesSummary>false</enableRulesSummary>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <!-- Use version from parent pom as that is adjusted according to the Java version used to run Maven -->
+        <version>${commons.findbugs.version}</version>
+        <configuration>
+          <excludeFilterFile>${basedir}/findbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
     </plugins>
 
   </build>


[4/6] [lang] Exclude SF_SWITCH_NO_DEFAULT on FastDateParser

Posted by pa...@apache.org.
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.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/c40dcf65
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/c40dcf65
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/c40dcf65

Branch: refs/heads/master
Commit: c40dcf659897edb26affa408c3fa62e80f906550
Parents: 3304965
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:18:53 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c40dcf65/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index f7623df..772052a 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -139,9 +139,14 @@
     <Method name="insertFormats" />
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
+  <!-- Reason: FindBugs does not correctly recognize default branches in switch statements without break statements.
+   See, e.g., the report at https://sourceforge.net/p/findbugs/bugs/1298 -->
   <Match>
     <Class name="org.apache.commons.lang3.time.FastDateParser"/>
-    <Method name="getStrategy" />
+    <Or>
+      <Method name="getStrategy" />
+      <Method name="simpleQuote" params="java.lang.StringBuilder, java.lang.String"/>
+    </Or>
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
 


[5/6] [lang] Add a default case to switch to appease FindBugs

Posted by pa...@apache.org.
Add a default case to switch to appease FindBugs


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9f7d03f0
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9f7d03f0
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9f7d03f0

Branch: refs/heads/master
Commit: 9f7d03f09172afcf0a7be40e3262d151ef053b3c
Parents: 8069e1c
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:16:52 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:58 2017 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/time/FastDateParser.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9f7d03f0/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
----------------------------------------------------------------------
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 e27acf4..9cf1a1c 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 @@ public class FastDateParser implements DateParser, Serializable {
                     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);


[2/6] [lang] FindBugs exclude filter for StringUtils

Posted by pa...@apache.org.
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.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/33049658
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/33049658
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/33049658

Branch: refs/heads/master
Commit: 3304965840c139dae7b8c01e1779a806641a0159
Parents: 5a52446
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 11:44:39 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/33049658/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index def3ec8..f7623df 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -58,7 +58,11 @@
   <!-- Reason: Optimization to use == -->
   <Match>
     <Class name="org.apache.commons.lang3.StringUtils" />
-    <Method name="indexOfDifference"/>
+    <Or>
+      <Method name="indexOfDifference"/>
+      <Method name="compare" params="java.lang.String,java.lang.String,boolean"/>
+      <Method name="compareIgnoreCase" params="java.lang.String,java.lang.String,boolean"/>
+    </Or>
     <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
   </Match>
 


[3/6] [lang] Exclude SF_SWITCH_FALLTHROUGH on FastDatePrinter

Posted by pa...@apache.org.
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.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/4d343ccc
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/4d343ccc
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/4d343ccc

Branch: refs/heads/master
Commit: 4d343ccc1181e306f8bb9431087ebb5e58b0c3c9
Parents: c40dcf6
Author: Allon Mureinik <am...@redhat.com>
Authored: Sat Apr 1 12:38:54 2017 +0300
Committer: pascalschumacher <pa...@gmx.net>
Committed: Wed Apr 19 18:24:57 2017 +0200

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/4d343ccc/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index 772052a..edc6ead 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -150,6 +150,13 @@
     <Bug pattern="SF_SWITCH_NO_DEFAULT" />
   </Match>
 
+  <!-- Reason: The fallthrough on the swich stateme is intentional -->
+  <Match>
+    <Class name="org.apache.commons.lang3.time.FastDatePrinter"/>
+    <Method name="appendFullDigits" params="java.lang.Appendable, int, int"/>
+    <Bug pattern="SF_SWITCH_FALLTHROUGH" />
+  </Match>
+
   <!-- Reason: Internal class that is used only as a key for an internal FormatCache. For this reason we can
    be sure, that equals will never be called with null or types other than MultipartKey.
   -->