2

I've been working on adding scalastyle to my scala project to check for potential problems in the code. But I keep getting empty results in the scalastyle-result xml file.

I've followed the steps from the scalastyle.org website. In summary here's what I did:

1- add the following to plugins.sbt

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

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

2- add the following line in build.sbt

org.scalastyle.sbt.ScalastylePlugin.Settings

3- add the file scalastyle-config.xml to the root directory of the project.

So now when I go to the sbt console, I can run "scalastyle" and I get the output file "scalastyle-result.xml" in ./target.

BUT the file only contains this:

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

So basically it is not raising any warnings. Now no need to mention that I do have a few classes in my project. But I am unable to distinguish whether the results xml is valid or not. I assume there should at least be a few warnings.

I've previously done some work with checkstyle which is quite similar, and in the ant target I got to specify the directory that checkstyle should be looking into. Is it similar with scalastyle?

Thanks a lot for the help.

flavian
  • 28,161
  • 11
  • 65
  • 105
static0886
  • 784
  • 9
  • 25
  • "scalastyle" should be in this question's tags list but I don't have enough reputation to add a new tag element :( – static0886 Jun 18 '13 at 10:47
  • Normally, scalastyle uses the setting scalaSource, so it should work. Do you have multiple source directories or something unusual like that? – Matthew Farwell Jun 18 '13 at 12:37
  • All my code is in ./app I'm a newb in Scala; where do I set scalaSource? I haven't come across this anywhere – static0886 Jun 18 '13 at 13:07
  • inside sbt do 'show scala-source'. This should give output like c:\xxx\src\main\scala. This is the value used by scalastyle. If this is different from where your sources are, then we have a problem :-) – Matthew Farwell Jun 18 '13 at 13:27
  • nope. it appears to point exactly to the folder with the code... – static0886 Jun 18 '13 at 14:06

1 Answers1

0

The output of scalastyle is stored in multiple locations.

There is a file target/scalastyle-result.xml in the root directory containing the results of root-code. This can be empty, or better, it only contains the headers but no warnings/issues.

However, when there is also code in another directory (app in your example), then the output will be stored in the target of this directory as app/target/scalastyle-result.xml.

kap
  • 1,456
  • 2
  • 19
  • 24