Questions tagged [spotbugs]

SpotBugs is a program which uses static analysis to look for bugs in Java code. SpotBugs is the spiritual successor of FindBugs, carrying on from the point where it left off with support of its community.

SpotBugs is a program which uses static analysis to look for bugs in Java, Groovy, Kotlin, Scala, JSP and Closure code.

SpotBugs is the spiritual successor of FindBugs, carrying on from the point where it left off with the support of its community. It is free software, distributed under the terms of the Lesser GNU Public License.

SpotBugs requires JRE (or JDK) 1.8.0 or later to run. However, it can analyze programs compiled for any version of Java, from 1.0 to 1.9.

165 questions
33
votes
1 answer

What to import to use @SuppressFBWarnings?

What to import to use SuppressFBWarnings? I installed the findbugs plugin via help / install new software When I type import edu., I can't do ctrl space to get the options. Example try { String t = null; …
user974465
26
votes
2 answers

Minimal working SpotBugs setup for Android Studio

How do I set up SpotBugs for Android? I tried following the official documentation and that of the gradle plugin, but the setup for Android is incomplete and confusing, and didn't work. I tried the following setup. build.gradle…
Terry
  • 14,529
  • 13
  • 63
  • 88
14
votes
1 answer

SpotBugs Maven Plugin exclude a directory

I use SpotBugs Maven Plugin for a static analysis and I would like to exclude a directory from the inspection. Looking at the spotbugs:check goal documentation, it seems that it is not possible to configure the plugin is such a way. I also checked…
Boris
  • 22,667
  • 16
  • 50
  • 71
12
votes
3 answers

Dealing with a Circular Dependency

I wonder if someone can advise on any good ways to break a circular dependency between 2 classes in Java.FindBugs proposes the use of interfaces so i wonder if someone has any good experience with this type of problem.
tropicana
  • 1,403
  • 2
  • 19
  • 27
12
votes
4 answers

How to run Spotbugs via Maven?

This is my pom.xml:
user1511417
  • 1,880
  • 3
  • 20
  • 41
10
votes
1 answer

How to ignore EI_EXPOSE_REP2 in case of spring autowired components

In my Spring Boot application, I use com.github.spotbugs:spotbugs-maven-plugin plugin. The spotbugs check reports no issues on following class: @Service public class FooService { @Autowired CocoComponent cocoComponent; @PostConstruct …
Ari Manninen
  • 306
  • 2
  • 7
9
votes
1 answer

Kotlin iterable

Given this class: data class CSVRecord(private val columns: SortedSet) : Iterable { override fun iterator(): Iterator { return columns.map { it.value }.iterator() } } spotbugs raises an error: [ERROR]…
David
  • 7,652
  • 21
  • 60
  • 98
8
votes
1 answer

Is there a way to lint incompatible Java API references with PMD, Checkstyle, SpotBugs, etc?

We are currently using Java Compiler 11 and deploy our main artifacts to Java 11. No problem here. Unfortunately, a service we use only supports Java 8 so we compile some of them targetting Java 8. No problem here. Our issue is that developers…
7
votes
0 answers

Why SpotBugs Gradle plugin always generate XML report instead of HTML?

I am using Gradle 5.2, spotbugs-gradle-plugin version 2.0.0 and tried to generate SpotBugs report on my project. I used the following configuration on my project but it always create XML reports instead of html report. buildscript { repositories…
SST
  • 2,054
  • 5
  • 35
  • 65
6
votes
2 answers

Checkstyle rule for suspicious integer division?

Is there a checkstyle rule that will catch something like this: double result = someInt / someOtherInt; result is double (so clearly fractions are desired) yet the right-hand side would do integer division (rounding down). Does something like this…
radai
  • 23,949
  • 10
  • 71
  • 115
6
votes
0 answers

Plugin with id 'com.github.spotbugs' not found

I'm configuring SpotBugs plugin for a Gradle project for the first time. buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } } dependencies { classpath…
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
6
votes
4 answers

Found reliance on default encoding: new java.io.FileWriter(File, boolean)

I'm using FileWrite class to write into a file.and its working fine. But FindBugs is pointing me a Minor issue in my code snippet. code snippet: SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd"); Date now = new Date(); …
kavie
  • 2,154
  • 4
  • 28
  • 53
6
votes
2 answers

Adding SpotBugs to my project

I've been working on adding SpotBugs to the android project I'm currently working on. I managed to get it working but I'm not overly thrilled of the way it's set up. For now the configuration resides inside my app/build.gradle file, which makes the…
Bohsen
  • 4,242
  • 4
  • 32
  • 58
5
votes
1 answer

Which plugin should I use when replacing FindBugs with SpotBugs on Jenkins?

I am using FindBugs now. I have heard that FindBugs is obsolete now. SpotBugs is the successor of FindBugs. I want to install SpotBugs plugins in my Jenkins. I have searched on the Available Plugins area for SpotBugs but didn't found anything. Also…
TAMIM HAIDER
  • 641
  • 1
  • 10
  • 19
5
votes
0 answers

How do I convert findbugsXml.xml to an excludeFilterFile?

I also asked this question on the SpotBugs issue tracker. Sorry, still using FindBugs, but we have a ticket in our backlog to upgrade to SpotBugs, and as far as I understand, configuration is the same and I only need to update groupId, artifactId…
Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
1
2 3
10 11