scalastyle产生空输出

问题描述 投票:1回答:1

我一直在努力为我的scala项目添加scalastyle来检查代码中的潜在问题。但是我一直在scalastyle-result xml文件中得到空结果。

我按照scalastyle.org网站上的步骤进行操作。总结一下,这就是我的所作所为:

1-将以下内容添加到plugins.sbt

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.3.1")

resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"

2-在build.sbt中添加以下行

org.scalastyle.sbt.ScalastylePlugin.Settings

3-将文件scalastyle-config.xml添加到项目的根目录。

所以现在当我进入sbt控制台时,我可以运行“scalastyle”,然后在./target中获取输出文件“scalastyle-result.xml”。

但该文件只包含这个:

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="5.0"></checkstyle>

所以基本上它没有提出任何警告。现在无需提及我的项目中有几个类。但我无法区分结果xml是否有效。我认为至少应该有一些警告。

我以前做过一些与checkstyle非常相似的工作,在ant目标中我必须指定checkstyle应该查看的目录。与scalastyle相似吗?

非常感谢您的帮助。

scala sbt checkstyle scalastyle
1个回答
0
投票

scalastyle的输出存储在多个位置。

根目录中有一个包含root-code结果的文件target/scalastyle-result.xml。这可以是空的,或者更好,它只包含标题但没有警告/问题。

但是,当另一个目录(在您的示例中为app)中也有代码时,输​​出将作为app/target/scalastyle-result.xml存储在此目录的目标中。

© www.soinside.com 2019 - 2024. All rights reserved.