| Number of watchers on Github | 26 |
| Number of open issues | 5 |
| Average time to close an issue | 3 days |
| Main language | Scala |
| Average time to merge a PR | 3 days |
| Open pull requests | 3+ |
| Closed pull requests | 2+ |
| Last commit | over 1 year ago |
| Repo Created | about 5 years ago |
| Repo Last Updated | over 1 year ago |
| Size | 101 KB |
| Organization / Author | etsy |
| Latest Release | 3.0.0 |
| Contributors | 6 |
| Page Updated | 2018-03-21 |
| Do you use sbt-checkstyle-plugin? Leave a review! | |
| View open issues (5) | |
| View sbt-checkstyle-plugin activity | |
| View on github | |
| Fresh, new opensource launches 🚀🚀🚀 | |
|
Trendy new open source projects in your inbox!
View examples
|
|
This project provides an SBT 0.13+ and 1.x plugin for running Checkstyle over Java source files. For more information about Checkstyle, see http://checkstyle.sourceforge.net/
This plugin uses version 6.15 of Checkstyle.
This is a fork of the sbt-code-quality project found here.
Add the following lines to project/plugins.sbt:
addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "3.1.1")
sbt-checkstyle-plugin is an AutoPlugin, so there is no need to modify the build.sbt file to enable it.
You can run Checkstyle over your Java source files with the
checkstyle task. You can run Checkstyle over your Java tests with
the test:checkstyle task.
The Checkstyle configuration file is ./checkstyle-config.xml by
default. This can be changed by setting the value of
checkstyleConfigLocation. By default test:checkstyle uses the same
configuration file, but this can be changed by setting the value of
checkstyleConfigLocation in Test.
The Checkstyle report is output to target/checkstyle-report.xml by
default. This can be changed by setting the value of
checkstyleOutputFile. test:checkstyle outputs to
target/checkstyle-test-report.xml, but this can be changed by
setting the value of checkstyleOutputFile in Test.
To change the checkstyle configuration file set checkstyleConfigLocation in build.sbt:
checkstyleConfigLocation := CheckstyleConfigLocation.File("checkstyle-config.xml")
You can also load remote configuration files by specifying a URL:
checkstyleConfigLocation :=
CheckstyleConfigLocation.URL("https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/checkstyle_checks.xml")
Or load configuration files from the classpath by specifying a resource name:
checkstyleConfigLocation := CheckstyleConfigLocation.Classpath("com/etsy/checkstyle-config.xml")
To run Checkstyle automatically after compilation:
(checkstyle in Compile) := (checkstyle in Compile).triggeredBy(compile in Compile).value
To run Checkstyle automatically after test compilation:
(checkstyle in Test) := (checkstyle in Test).triggeredBy(compile in Test).value
The checkstyleXsltTransformations setting allows applying XSLT transformations to the XML report generated by Checkstyle. For instance, this could be used to generate a more readable HTML report. This setting takes values of Option[Set[XSLTSettings]], so multiple transformations can be applied.
You can set checkstyleXsltTransformations like so in build.sbt:
checkstyleXsltTransformations := {
Some(Set(CheckstyleXSLTSettings(baseDirectory(_ / "checkstyle-noframes.xml").value, target(_ / "checkstyle-report.html").value)))
}
You can control what severity of issues should break the build by setting the checkstyleSeverityLevel in your build.sbt as follows:
checkstyleSeverityLevel := Some(CheckstyleSeverityLevel.Error)
Possible values are defined by the CheckstyleSeverityLevel enumeration. The default is None.
If you want to run Checkstyle on your integration tests add the following to your build.sbt:
lazy val root = (project in file(".")).configs(IntegrationTest)
Defaults.itSettings
checkstyleConfigLocation := CheckstyleConfigLocation.File("my-checkstyle-config.xml"),
checkstyle in IntegrationTest := checkstyleTask(IntegrationTest).value,
checkstyleOutputFile in IntegrationTest := target.value / "checkstyle-integration-test-report.xml"
You can then run the tasks it:checkstyle and it:checkstyle-check.
SBT Checkstyle plugin comes with a default Checkstyle version: currently, Checkstyle 6.15 is used by default.
Provided the new Checkstyle version is compatible, you can override the version used at runtime in your project/plugins.sbt:
dependencyOverrides += "com.puppycrawl.tools" % "checkstyle" % "6.15"
checkstyleOutputFileSome(target.value / "checkstyle-report.xml")
checkstyleConfigLocationCheckstyleConfigLocation.{File, URL, Classpath}
CheckstyleConfigLocation.File("checkstyle-config.xml")
checkstyleXsltTransformationsSome(Set[CheckstyleXSLTSettings])
None
checkstyleSeverityLevelSome(CheckstyleSeverityLevel.{Ignore, Info, Warning, Error})
None
Thanks to @JosephEarl sbt-checkstyle-plugin now follows the best practices guide for SBT plugins. The changes include:
The names of the setting and task keys changed in this release. Check the README for updated information on configuring and using the plugin.
This release upgrades to Checkstyle 6.15.
If you would like to use a different version of Checkstyle, see the instructions here: https://github.com/etsy/sbt-checkstyle-plugin#upgrading-checkstyle-version
sbt-checkstyle-plugin is now an AutoPlugin. As such there is no need to manually enable the plugin.
In addition, several breaking changes were made in this release:
The README has been updated to reflect these changes.