diff options
author | Mario Pastorelli <mario.pastorelli@teralytics.ch> | 2016-09-14 12:38:41 +0200 |
---|---|---|
committer | Mario Pastorelli <mario.pastorelli@teralytics.ch> | 2016-09-14 12:41:05 +0200 |
commit | 3eae7ef24066cc699bddbd6a6c593929948bdb2f (patch) | |
tree | 4c7e9e49a59c135474cef70cc8f3be0b8d931fd3 /plugins/wartremover | |
parent | 1630cdae28c8d29a4502446a2d14d7bb5b30fb98 (diff) | |
download | cbt-3eae7ef24066cc699bddbd6a6c593929948bdb2f.tar.gz cbt-3eae7ef24066cc699bddbd6a6c593929948bdb2f.tar.bz2 cbt-3eae7ef24066cc699bddbd6a6c593929948bdb2f.zip |
WartRemover plugin implementation (#167)
Diffstat (limited to 'plugins/wartremover')
-rw-r--r-- | plugins/wartremover/WartRemover.scala | 51 | ||||
-rw-r--r-- | plugins/wartremover/build/build.scala | 9 |
2 files changed, 60 insertions, 0 deletions
diff --git a/plugins/wartremover/WartRemover.scala b/plugins/wartremover/WartRemover.scala new file mode 100644 index 0000000..d5bbcd0 --- /dev/null +++ b/plugins/wartremover/WartRemover.scala @@ -0,0 +1,51 @@ +package cbt + +import org.wartremover.WartTraverser +import java.io.File + +trait WartRemover extends BaseBuild { + + override def scalacOptions = + super.scalacOptions ++ wartremoverScalacOptions + + private[this] def wartremoverCompilerDependency: String = + MavenResolver( + context.cbtHasChanged, + context.paths.mavenCache, + mavenCentral).bindOne( + ScalaDependency("org.wartremover", "wartremover", "1.1.1") + ).jar.string + + private[this] def wartremoverScalacOptions: Seq[String] = + Seq("-Xplugin:" ++ wartremoverCompilerDependency) ++ + wartremoverErrorsScalacOptions ++ + wartremoverWarningsScalacOptions ++ + wartremoverExcludedScalacOptions ++ + wartremoverClasspathsScalacOptions + + private[this] def wartremoverErrorsScalacOptions: Seq[String] = + wartremoverErrors.distinct.map(w => s"-P:wartremover:traverser:${w.className}") + + private[this] def wartremoverWarningsScalacOptions: Seq[String] = + wartremoverWarnings.distinct + .filterNot(wartremoverErrors contains _) + .map(w => s"-P:wartremover:only-warn-traverser:${w.className}") + + private[this] def wartremoverExcludedScalacOptions: Seq[String] = + wartremoverExcluded.distinct.map(c => s"-P:wartremover:excluded:${c.getAbsolutePath}") + + private[this] def wartremoverClasspathsScalacOptions: Seq[String] = + wartremoverClasspaths.distinct.map(cp => s"-P:wartremover:cp:$cp") + + /** List of Warts that will be reported as compilation errors. */ + def wartremoverErrors: Seq[WartTraverser] = Seq.empty + + /** List of Warts that will be reported as compilation warnings. */ + def wartremoverWarnings: Seq[WartTraverser] = Seq.empty + + /** List of files to be excluded from all checks. */ + def wartremoverExcluded: Seq[File] = Seq.empty + + /** List of classpaths for custom Warts. */ + def wartremoverClasspaths: Seq[String] = Seq.empty +} diff --git a/plugins/wartremover/build/build.scala b/plugins/wartremover/build/build.scala new file mode 100644 index 0000000..d62c571 --- /dev/null +++ b/plugins/wartremover/build/build.scala @@ -0,0 +1,9 @@ +import cbt._ + +class Build(val context: Context) extends Plugin { + override def dependencies = + super.dependencies ++ + Resolver( mavenCentral ).bind( + ScalaDependency("org.wartremover", "wartremover", "1.1.1") + ) +} |