如何启用scala linter?

前端之家收集整理的这篇文章主要介绍了如何启用scala linter?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我将build.sbt添加directed

addCompilerPlugin("org.psywerx.hairyfotr" %% "linter" % "0.1.14")

怎么办?我可以像往常一样编译我的项目,但是看不到linter的任何输出.我需要运行一个特殊的sbt任务吗?

解决方法

从他们 documentation

terminal:
  scalac -Xplugin:<path-to-linter-jar>.jar ...

sbt: (in build.sbt)
  scalacOptions += "-Xplugin:<path-to-linter-jar>.jar"

maven: (in pom.xml inside scala-maven-plugin configuration)
  <configuration>
    <args>
      <arg>-Xplugin:<path-to-linter-jar>.jar</arg>
    </args>
  </configuration>

但是,对我来说,只需添加编译器插件即可.一个简单的测试方法是在这里放一个这样的方法

def f(a: Int) = 10

您应该收到如下警告:

Parameter a is not used in method f.
[warn]   def f(a: Int) = 10
[warn]       ^

猜你在找的Scala相关文章