From 0cf4d97f3a8918b8c4fa41282585f78addbe36f9 Mon Sep 17 00:00:00 2001 From: Arnab Nandy Date: Sat, 18 Jul 2026 15:07:39 +0530 Subject: [PATCH] build: replace FindBugs with SpotBugs Signed-off-by: Arnab Nandy --- .../google-http-client-findbugs-test/pom.xml | 10 ++--- google-http-client-findbugs/pom.xml | 32 +++++----------- .../api/client/findbugs/BetaDetector.java | 37 ++++++++----------- .../api/client/findbugs/package-info.java | 9 +++-- .../src/main/resources/messages.xml | 2 +- .../java/com/google/api/client/util/Beta.java | 5 ++- pom.xml | 12 +++--- .../dailymotion-simple-cmdline-sample/pom.xml | 6 +-- findbugs-exclude.xml => spotbugs-exclude.xml | 2 +- 9 files changed, 50 insertions(+), 65 deletions(-) rename findbugs-exclude.xml => spotbugs-exclude.xml (98%) diff --git a/google-http-client-findbugs/google-http-client-findbugs-test/pom.xml b/google-http-client-findbugs/google-http-client-findbugs-test/pom.xml index 461d1241a..5618a517a 100644 --- a/google-http-client-findbugs/google-http-client-findbugs-test/pom.xml +++ b/google-http-client-findbugs/google-http-client-findbugs-test/pom.xml @@ -4,8 +4,8 @@ 4.0.0 com.google.http-client google-http-client-findbugs-test - 1.15.0-rc-SNAPSHOT - Findbugs Google API Client Library plugin test. + 2.1.2-SNAPSHOT + SpotBugs Google API Client Library plugin test. jar @@ -30,9 +30,9 @@ - org.codehaus.mojo - findbugs-maven-plugin - 3.0.5 + com.github.spotbugs + spotbugs-maven-plugin + 4.8.6.8 diff --git a/google-http-client-findbugs/pom.xml b/google-http-client-findbugs/pom.xml index e394c1218..832922dba 100644 --- a/google-http-client-findbugs/pom.xml +++ b/google-http-client-findbugs/pom.xml @@ -9,7 +9,11 @@ google-http-client-findbugs 2.1.2-SNAPSHOT - Google APIs Client Library Findbugs custom plugin. + Google APIs Client Library SpotBugs custom plugin. + + SpotBugs plugin for detecting usages of beta Google HTTP Client APIs. The artifact ID retains + its historical name for compatibility. + @@ -50,28 +54,10 @@ - com.google.code.findbugs - findbugs - 3.0.1 - - - xalan - xalan - - - xmlParserAPIs - xerces - - - annotations - com.google.code.findbugs - - - - - com.google.code.findbugs - bcel-findbugs - 6.0 + com.github.spotbugs + spotbugs + 4.8.6 + provided com.google.http-client diff --git a/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/BetaDetector.java b/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/BetaDetector.java index 791d37f39..c6f1fdaae 100644 --- a/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/BetaDetector.java +++ b/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/BetaDetector.java @@ -18,6 +18,9 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.bcel.OpcodeStackDetector; +import edu.umd.cs.findbugs.visitclass.Constants2; +import org.apache.bcel.Const; +import org.apache.bcel.Constants; import org.apache.bcel.Repository; import org.apache.bcel.classfile.AnnotationEntry; import org.apache.bcel.classfile.ConstantClass; @@ -26,11 +29,11 @@ import org.apache.bcel.classfile.Method; /** - * Findbugs plugin detector which detects usage of {@link Beta} in your code. + * SpotBugs plugin detector which detects usage of {@link Beta} in your code. * * @author Eyal Peled */ -public class BetaDetector extends OpcodeStackDetector { +public class BetaDetector extends OpcodeStackDetector implements Constants, Constants2 { /** Beta annotation "signature". */ private static final String BETA_ANNOTATION = "Lcom/google/api/client/util/Beta;"; @@ -54,33 +57,25 @@ public BetaDetector(BugReporter bugReporter) { @Override public void sawOpcode(int seen) { switch (seen) { - case INVOKEINTERFACE: - case INVOKESTATIC: - case INVOKESPECIAL: - case INVOKEVIRTUAL: + case Const.INVOKEINTERFACE: + case Const.INVOKESTATIC: + case Const.INVOKESPECIAL: + case Const.INVOKEVIRTUAL: // Method usage checkMethod(getNameConstantOperand(), getSigConstantOperand()); break; - case GETFIELD: - case GETFIELD_QUICK: - case GETFIELD_QUICK_W: - case PUTFIELD: - case PUTFIELD_QUICK: - case PUTFIELD_QUICK_W: - case GETSTATIC: - case GETSTATIC_QUICK: - case GETSTATIC2_QUICK: - case PUTSTATIC: - case PUTSTATIC_QUICK: - case PUTSTATIC2_QUICK: + case Const.GETFIELD: + case Const.PUTFIELD: + case Const.GETSTATIC: + case Const.PUTSTATIC: // Field usage checkField(getNameConstantOperand()); break; - case LDC: - case LDC_W: - case LDC2_W: + case Const.LDC: + case Const.LDC_W: + case Const.LDC2_W: // Class usage if (getConstantRefOperand() instanceof ConstantClass) { // report bug in case it's google api @Beta class diff --git a/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java b/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java index 83168807c..cfcc251c2 100644 --- a/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java +++ b/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java @@ -13,14 +13,17 @@ */ /** - * Findbugs package which supports custom Google APIs Client library findbugs Plugins. + * SpotBugs package which supports the custom Google APIs Client Library SpotBugs plugin. + * + *

The artifact ID retains its historical {@code google-http-client-findbugs} name for + * compatibility. * *

Usage on pom.xml: * *

  * <plugin>
- * <groupId>org.codehaus.mojo</groupId>
- * <artifactId>findbugs-maven-plugin</artifactId>
+ * <groupId>com.github.spotbugs</groupId>
+ * <artifactId>spotbugs-maven-plugin</artifactId>
  * ...
  * <configuration>
  * <plugins>
diff --git a/google-http-client-findbugs/src/main/resources/messages.xml b/google-http-client-findbugs/src/main/resources/messages.xml
index b6ce0d8b3..ebd2e87a8 100644
--- a/google-http-client-findbugs/src/main/resources/messages.xml
+++ b/google-http-client-findbugs/src/main/resources/messages.xml
@@ -3,7 +3,7 @@
   xsi:noNamespaceSchemaLocation="messagecollection.xsd">
 
   
-    FindBugs Google API's Client library plugin
+    SpotBugs Google APIs Client Library plugin
     
Provides detectors for Google APIs Client library.
diff --git a/google-http-client/src/main/java/com/google/api/client/util/Beta.java b/google-http-client/src/main/java/com/google/api/client/util/Beta.java index 87e4f710f..dd92e8102 100644 --- a/google-http-client/src/main/java/com/google/api/client/util/Beta.java +++ b/google-http-client/src/main/java/com/google/api/client/util/Beta.java @@ -36,8 +36,9 @@ * used in client applications, and if the wrong version of this library is used, it has the * potential to break client applications. * - *

You may use the google-http-client-findbugs plugin to find usages of API bearing this - * annotation. + *

You may use the SpotBugs plugin in the {@code google-http-client-findbugs} artifact to find + * usages of API bearing this annotation. The artifact ID retains its historical name for + * compatibility. * * @since 1.15 * @author Eyal Peled diff --git a/pom.xml b/pom.xml index 4155d00a5..69637f902 100644 --- a/pom.xml +++ b/pom.xml @@ -366,9 +366,9 @@ 3.6.0 - org.codehaus.mojo - findbugs-maven-plugin - 3.0.5 + com.github.spotbugs + spotbugs-maven-plugin + 4.8.6.8 org.codehaus.mojo @@ -503,10 +503,10 @@ - org.codehaus.mojo - findbugs-maven-plugin + com.github.spotbugs + spotbugs-maven-plugin - ${basedir}/../findbugs-exclude.xml + ${basedir}/../spotbugs-exclude.xml com.google.http-client diff --git a/samples/dailymotion-simple-cmdline-sample/pom.xml b/samples/dailymotion-simple-cmdline-sample/pom.xml index 5845e416f..1cec775e6 100644 --- a/samples/dailymotion-simple-cmdline-sample/pom.xml +++ b/samples/dailymotion-simple-cmdline-sample/pom.xml @@ -45,10 +45,10 @@ - org.codehaus.mojo - findbugs-maven-plugin + com.github.spotbugs + spotbugs-maven-plugin - ../../findbugs-exclude.xml + ../../spotbugs-exclude.xml false diff --git a/findbugs-exclude.xml b/spotbugs-exclude.xml similarity index 98% rename from findbugs-exclude.xml rename to spotbugs-exclude.xml index 09ee3ab9e..9f9405165 100644 --- a/findbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -1,7 +1,7 @@ - +