jon
jon

Reputation: 263

Spotbugs to find bugs in java file

Currently we are running spot bugs against jars to find the bugs. Is there any way to run spotbugs over a single java file to find the list of bugs in it

Upvotes: 2

Views: 1601

Answers (2)

Arpan Kanthal
Arpan Kanthal

Reputation: 503

A quick search gave me the following link. https://spotbugs.readthedocs.io/en/stable/filter.html.
I didn't get a chance to test it out, but from what I read, it looks like you can supply an XML configuration file where you would filter in only the class you need.
The below snippet must work.

<Match>
   <Class name="com.foobar.MyClass" />
</Match>

However if you are looking for static code analysis on demand, you could just install the findbugs plugin on intellij and use it on demand

Upvotes: 1

Matthias
Matthias

Reputation: 323

Spotbugs works with compiled Java files. That means it analizes .class files which exist in .jar files.

It's not possible to analize the java files without compiling them first.

Upvotes: 0

Related Questions