Questions tagged [scalastyle]

Scalastyle is a style checker for Scala.

Scalastyle examines your Scala code and indicates potential problems with it. If you have come across Checkstyle for Java, then you’ll have a good idea what scalastyle is. Except that it’s for Scala obviously.

For more information, see http://www.scalastyle.org/

51 questions
67
votes
5 answers

What's the current state of static analysis tools for Scala?

I saw a StackOverflow question regarding static analysis in Scala, but that one was answered in 2009. As you know, the Scala tools are changing very rapidly. I was therefore wondering if someone familiar with the current state of static analysis…
marekinfo
  • 1,434
  • 1
  • 12
  • 12
40
votes
3 answers

How to suppress Scalastyle warning?

I got following code: string match { case Regex(_, "1", "0", _, _) => case Regex(_, "1", "1", null, _) => } Scalastyle is complaining about usage of null which cannot be avoided here. Any way I can suppress warning just for…
Kiril
  • 998
  • 1
  • 11
  • 20
17
votes
1 answer

Is there a better way to setup ScalaStyle under IntelliJ?

There's some scalastyle support in the Scala plugin for IntelliJ. This question is about the best way to set it up to pick up a scalastyle configuration file which is customarily at the root of the directory under the name scalastyle-config.xml…
Francois G
  • 11,957
  • 54
  • 59
7
votes
3 answers

Scalastyle "Public method must have explicit type" in Play Framework

We've started experimenting with Scala and the Play framework at my work. Setup our auto-linting and testing framework as the first thing, and have deployed Scalastyle to handle the former. That has been very useful, except that we are getting this…
Michael A.
  • 4,163
  • 3
  • 28
  • 47
6
votes
0 answers

IntelliJ - How to force named parameters in Scala editor and add them

Basically I want the IDE to enforce named parameters syntax when it is auto-completing https://docs.scala-lang.org/style/method-invocation.html So for example a given class class MyClass { def myMethod( param1 : String, param2 : String) } I want…
Avba
  • 14,822
  • 20
  • 92
  • 192
6
votes
6 answers

Scala "def" method declaration: Colon vs equals

I am at the early stages of learning Scala and I've noticed different ways to declare methods. I've established that not using an equals sign makes the method a void method (returning a Unit instead of a value), and using an equals sign returns the…
Marco Prins
  • 7,189
  • 11
  • 41
  • 76
5
votes
4 answers

Simplifying Option[Boolean] expression in Scala

I have code like that: optionBoolean.getOrElse(false) && otherOptionBoolean.getOrElse(false) And Scalastyle tells me that it can be simplified. How?
Ava
  • 818
  • 10
  • 18
5
votes
2 answers

Scalastyle Boolean expression can be simplified

Scalastyle (intellij 2016.1 defaults) says this boolean expression can be simplified val t = Option(true) val f = Option(false) if(t.contains(true) && f.contains(false)) { println("booop") } I can get rid of this by changing the if…
klogd
  • 1,118
  • 11
  • 19
4
votes
1 answer

How to failed compilation if there are any dead code or unused imports, variables etc

I am trying to failed compilation if there are any unused imports, local or private variables or dead code in the codebase. So, I have added following scalacoptions. scalacOptions ++= Seq( "-encoding", "UTF-8", "-Xfatal-warnings", …
Mahesh Chand
  • 3,158
  • 19
  • 37
4
votes
0 answers

How to skip Scalastyle during sbt build?

Is it possible to run an sbt build and disable Scalastyle for just this run, using a command line argument? I'm thinking of something similar to Checkstyle's (with Maven) -Dcheckstyle.skip=true, but cannot seem to find anything similar in the…
Cedric Reichenbach
  • 8,970
  • 6
  • 54
  • 89
4
votes
1 answer

How to publish Scalastyle results in Jenkins Maven job?

We have a Scala project and use Maven and Jenkins for building it. Now we also want to use Scalastyle for static code analysis. It works fine in the IDE and if I use a Jenkins freestyle job. The output file is created and Jenkins shows a nice graph…
Kathi
  • 323
  • 2
  • 13
3
votes
1 answer

How to supress a specific scalastyle rule in IDEA?

I want to suppress no.finalize rule of ScalaStyle only for one particular class. I figured that one approach to suppress IntelliJ IDEA's inspection is to add following comment at the beginning of the class: //noinspection ScalaStyle However, this…
vatsal mevada
  • 5,148
  • 7
  • 39
  • 68
3
votes
0 answers

Comments on scalastyle:ignore

When I tell scalastyle to ignore a line, I would like to put a comment in the code explaining to future developers why that line deserves exemption from the normal rules. I can obviously put it in the previous line, like: // might be called from…
Nathan Kronenfeld
  • 473
  • 1
  • 5
  • 14
3
votes
1 answer

it:scalastyle not working for integration tests' folder

The scalastyle configuration in build.sbt is set as follows: (scalastyleConfig in Test) := baseDirectory.value / "scalastyle-config.xml" (scalastyleConfig in IntegrationTest) := baseDirectory.value / "scalastyle-config.xml" Nevertheless, the sbt…
Dvin
  • 149
  • 1
  • 5
3
votes
1 answer

Is there a way to specify an alternate scalastyle-config.xml under IntelliJ for test scope?

In build.sbt you can specify an alternate scalastyle config file for test scope using this: (scalastyleConfig in Test) := baseDirectory.value / "scalastyle-test-config.xml" This is useful when you want to loosen the checks in Test…
sfosdal
  • 796
  • 11
  • 23
1
2 3 4