FindBugs static analysis plugin for sbt.
This sbt plug-in enables you to analyze your (Java) code with the help of the great
FindBugs tool. It defines a findbugs
sbt action for that purpose.
Install the plugin by adding the following to project/plugins.sbt
:
addSbtPlugin("com.github.sbt" % "sbt-findbugs" % "<version>")
And then run the plugin with sbt findbugs
. This will generate a FindBugs report in
target/scala-xx/findugs/report.xml
.
Just use Scala inline XML for the setting, for example:
findbugsIncludeFilters := Some(<FindBugsFilter>
<Match>
<Class name="de.johoop.Meep" />
</Match>
</FindBugsFilter>)
You can also read the filter settings from files in a more conventional way:
findbugsIncludeFilters := Some(baseDirectory.value / "findbugs-include-filters.xml")
Or, when your configuration is zipped and previously published to a local repo:
findbugsIncludeFilters := {
val configFiles = update.value.select(module = moduleFilter(name = "velvetant-sonar"))
val configFile = configFiles.headOption flatMap { zippedFile =>
IO.unzip(zippedFile, target.value / "rules") find (_.name contains "velvetant-sonar-findbugs.xml")
}
configFile map scala.xml.XML.loadFile orElse sys.error("unable to find config file in update report")
}
(see also the FindBugs documentation)
findbugsReportType
Some(FindbugsReportType.{Xml, Html, PlainHtml, FancyHtml, FancyHistHtml, Emacs, Xdoc})
Some(FindbugsReportType.Xml)
findbugsReportPath
Some(crossTarget.value / "findbugs" / "report.xml")
findbugsPriority
FindbugsPriority.{Relaxed, Low, Medium, High}
FindbugsPriority.Medium
findbugsEffort
FindbugsEffort.{Minimum, Default, Maximum}
FindbugsEffort.Default
findbugsOnlyAnalyze
List[String]
of packages and classes.None
(meaning: analyze everything).findbugsMaxMemory
1024
findbugsAnalyzeNestedArchives
true
and false
true
findbugsSortReportByClassNames
true
and false
false
findbugsIncludeFilters
None
and Option[Node]
None
(no include filters).findbugsExcludeFilters
None
and Some[Node]
None
(no exclude filters).findbugsAnalyzedPath
sbt.Path
Seq(classDirectory in Compile value)
Thanks to @asflierl and @anishathalye for their contributions!
Copyright (c) Joachim Hofer & contributors
All rights reserved.
This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html