JetBrains / spotbugs-intellij-plugin

The SpotBugs Plugin for IntelliJ IDEA
GNU Lesser General Public License v2.1
71 stars 33 forks source link

Spotbugs IDEA plugin is not catching a bug that Spotbugs maven plugin is catching #19

Open TheLoneKing opened 4 years ago

TheLoneKing commented 4 years ago

The spotbugs maven plugin reports the NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE bug in a couple of places in my code. However, when I analyze the same project Intellij, the plugin is not catching those bugs.

The spotbugs configuration on my Intellij IDE is as below: Analysis effort: Maximal Minimum rank: 20 - Of Concern Minimum confidence: Low

I have also enabled all the providers.

Here's my maven plugin config:

<plugin>
    <groupId>com.github.spotbugs</groupId>
    <artifactId>spotbugs-maven-plugin</artifactId>
    <version>4.0.0</version>
    <configuration>
        <includeTests>true</includeTests>
        <effort>Max</effort>
        <threshold>Low</threshold>
    </configuration>
    <executions>
        <execution>
            <id>check</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>
jqyp commented 4 years ago
I can't reproduce the problem: Screenshot 2020-05-08 at 22 58 49 You have enabled the “Dodgy code (STYLE)“ checkbox and a “FindNullDeref“ one, right? Dodgy code (STYLE) FindNullDeref
Screenshot 2020-05-09 at 00 12 57 Screenshot 2020-05-08 at 22 37 12

If it's that, provide a minimal code example for which IntelliJ SpotBugs plugin doesn't catch a bug.

RogerVFbr commented 4 years ago

We have a similar issue. Spotbugs Maven plugin finds many bugs that Intellij's plugin doesn't . In our platform, both instances are producing different results. InteliiJ's is configured to consider all "Reports" and "Detectors", while Maven's is running on default settings. In the depicted example we are using an "inclusion" xml file to narrow down the results and quicken the test. It's configuration works properly via Maven and seems to be working normally in Intellij as well. The project has no suppression annotations. The problem has been reproduced locally both in 2019.3 and 2020.1 versions on 2 different computers. We use OSX Catalina, Java 1.8. Plugin version is 1.1.0.

Unfortunately, I could not yet reproduce the problem on a minimal code example. It seems you need a mass of occurrences for the problem to arise.

Screen Shot 2020-05-13 at 16 47 55

Screen Shot 2020-05-13 at 16 48 32

Screen Shot 2020-05-13 at 16 58 32

Screen Shot 2020-05-13 at 16 58 52

Screen Shot 2020-05-13 at 17 01 26

TheLoneKing commented 4 years ago

@jqyp Yes, I have enabled all necessary settings.

report_settings

detector_settings

Here's the result of scanning the code with Spotbugs Intellij plugin (problem is in addNewItems method): plugin_no_error

Same code scanned with maven plugin reports error: mvn_error

marcopelegrini commented 4 years ago

I can simulate this using a simple SpringBoot Application:

image

image

image

BTW, the error is a false positive, trimAllWhitespace is null safe

TremotinoVolante commented 3 years ago

Hi, same problem here :/

We had an exercise at university to learn about SpotBugs and the SpotBugs via maven plugin

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.2.0</version>
<dependencies>
    <dependency>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs</artifactId>
        <version>4.2.3</version>
    </dependency>
</dependencies>
</plugin>

works fine: it finds all bugs in the exercise. But the "SpotBugs plugin 1.2.4 with SpotBugs version 4.1.3" finds not a single bug. They are also quite obvious: even IntelliJ highlights them. What am I doing wrong?

I can also provide a minimal working code example:

public class Student {

    private String firstName;

    public Student(String firstName) {
        setFirstName(firstName);
    }

    public void setFirstName(String firstName) {
        this.firstName.replaceAll("[^A-Za-z]", "");
    }

    public static void main(String[] args) {
        Student oliver = new Student("Oliver");
    }
}

the bug is in line 10: this.firstName.replaceAll("[^A-Za-z]", ""); instead of this.firstName=firstName.replaceAll("[^A-Za-z]", "");

The Sputbugs IDEA plugin is just giving me this answer:

Screenshot 2021-07-09 at 11 21 43

it says no class files found but if I click on "more" it says the class Student has been analysed.

image

maven on the other side:

Screenshot 2021-07-09 at 11 31 01

I'm using both maven and IDEA plugin with default setting.

Im using: IntelliJ IDEA 2021.1.3 (Ultimate Edition) Build #IU-211.7628.21, built on June 30, 2021 Non-Bundled Plugins: org.jetbrains.plugins.spotbugs (1.2.4),

miguno commented 5 months ago

+1

I have the same issue as described in 14.4.1 (23E224).

Environment

IntelliJ IDEA:

Spotbugs IntelliJ Plugin:

OS:

Java: