Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding non-java classes from findbugs

I have a mixed scala/java project - mostly java. I would like to use Findbugs on my java code, but the scala classes are giving it trouble. So I'd like to exclude them from Findbugs. So far I've tried listing the scala classes in an exclude filter, but that's not helping. I'm using the maven codehaus findbugs plugin version 2.3.1.

The exceptions I'm getting mostly take this form:

Exception analyzing some.scala.Class using detector edu.umd.cs.findbugs.detect.FindUnrelatedTypesInGenericContainer
  java.lang.NullPointerException
    At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM$1$2.visitEnd(ClassParserUsingASM.java:319)
    At org.objectweb.asm.ClassReader.accept(Unknown Source)
    At edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44)
    At org.objectweb.asm.ClassReader.accept(Unknown Source)
    At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:93)
    At edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:414)
    At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:65)
    At edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:39)
    At edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:214)
    At edu.umd.cs.findbugs.ba.XFactory.getXClass(XFactory.java:581)
    At edu.umd.cs.findbugs.ba.AnalysisCacheToAnalysisContextAdapter.setAppClassList(AnalysisCacheToAnalysisContextAdapter.java:319)
    At edu.umd.cs.findbugs.FindBugs2.createAnalysisContext(FindBugs2.java:785)
    At edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:187)
    At edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:348)
    At edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1057)
like image 205
sblundy Avatar asked Sep 20 '10 17:09

sblundy


1 Answers

Not really a solution, but FindBugs should work for Scala generated class files as well, so I'd suggest to report these errors to the FindBugs team. Of course the analysis of FindBugs might be not very helpful for Scala classes in most cases (because of the heavy compiler magic), but at least FindBugs shouldn't crash. I hope that sooner or later FindBugs will be extended to give Scala classes a special treatment (but that won't happen if nobody complains :-)

like image 150
Landei Avatar answered Oct 03 '22 08:10

Landei