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
1
vote
1 answer

How to specific Scala style rules for a specific file/directory?

I have some cucumber stepDef steps which are more than more than 120 characters in length, I want to exclude all stepDef files from Scala style warning. Is there a way to to exclude a specific files/directories, using xml tag only for…
Puneeth Reddy V
  • 1,538
  • 13
  • 28
1
vote
0 answers

Static Code Analyzer to enforce Type Annotation in Scala

Is there any static code analyzer that can be used to enforce Type Annotation in Scala. For example, when a developer writes a statement without type annotation as show in the example below, he should get a compile time error val name="sometime"…
Raj
  • 2,368
  • 6
  • 34
  • 52
1
vote
1 answer

Use of scalastyleConfigUrl

I am very new to Scala and SBT I am trying to set up the project with Scalastyle. All works fine when running from command line, however I can't find a way to define the option as indicated on the Scalastyle website…
ab_732
  • 3,639
  • 6
  • 45
  • 61
1
vote
1 answer

Reassign ArrayList in a better Way

The below code is working, but its looking odd to me, is there any better way to this. var res:scala.collection.mutable.LinkedHashMap[String,scala.collection.immutable.Map[String,String]]=?? var arList = new…
Govind Singh
  • 15,282
  • 14
  • 72
  • 106
1
vote
1 answer

Setting a third-party plugin setting in sbt AutoPlugin

I have an AutoPlugin which aggregates several third-party plugins and customizes their settings for our company. For most of the plugins, this works just fine by putting them in the projectSettings: override lazy val projectSettings = Seq(…
Justin Kaeser
  • 5,868
  • 27
  • 46
1
vote
1 answer

How to use the EnsureSingleSpaceAfterTokenChecker in scalastyle

I'm using the maven plugin for scalastyle. The Scalastyle site lists EnsureSingleSpaceAfterTokenChecker as one of the new checkers, but doesn't give an example of how to use it. I'm sure it's used like typical checkers, but I'm not sure how to…
Inbl
  • 630
  • 2
  • 5
  • 18
0
votes
0 answers

Check multiple header using Scalastylesheet org.scalastyle.file.HeaderMatchesChecker

Whenever we build a new class on top of open source, we usually add our own licence (instead of the apache one, which is there by default in our open source project). Now the problem is scala style sheet checks for headers using…
Vijay Jangir
  • 584
  • 3
  • 15
0
votes
0 answers

illegal start of simple expression in if-statement

I have some issues with scala. I got this error when I run scalastyle illegal start of simple expression This question is linked with other questions about scalastyle illagal error but I tried all solutions proposed but nothing has fixed the…
Marc
  • 320
  • 2
  • 9
0
votes
0 answers

How to configure the regex in scalstyleCheck for header check?

Suppose I want to check that my every scala file has a header similar to /* * Copyright (c) 2020-2021 XYZ company ltd * All Rights Reserved. */ Now the scalastyle_config.xml has an entry like
Jeet
  • 85
  • 3
  • 8
0
votes
1 answer

Scala checkstyle - Ignoring specific files for check

I've got a scalastyle_config.xml file with the following check, among others:
0
votes
1 answer

Scala case-match optimization for performance and readability

I wrote the below for pattern matching in scala : scala> val rowMap = Map("abc" -> null) rowMap: scala.collection.immutable.Map[String,Null] = Map(abc -> null) scala> val postgresKey = "abc" postgresKey: String = abc scala> val h2Key =…
ForeverLearner
  • 1,901
  • 2
  • 28
  • 51
0
votes
0 answers

Custom regex for scalastyle for catching missed whitespaces

I want to write a custom regex for scalastyle so that it could catch cases when a developer forget a whitespaces before and after operators, but the regex shouldn't catch anything inside the string. Let's see the examples: val asdf123=sdf // should…
alex
  • 942
  • 1
  • 10
  • 26
0
votes
1 answer

Migration to sbt 1: how to run Scalastyle at compilation time

I had scalastyle running at compilation time in my project. Since I updated from sbt 0.13 to sbt 1.0.1 I don't manage to make it work again. I followed the documentation from here and added this to my build.sbt: lazy val compileScalaStyle:…
Simon
  • 6,025
  • 7
  • 46
  • 98
0
votes
1 answer

ScalaStyle using grade return an error

I'm looking for scalaStyle using gradle. Can you explain how to do it? I've tried this link, but I get an error: Error:(110, 0) Could not find method scalaStyle() for arguments [build_5ig236mubh10t6rxyt8apdkfi$_run_closure4@46b9e954] on root …
kevinjoeiy
  • 111
  • 2
  • 12
0
votes
0 answers

Indentation level of multi-line case class in scalastyle

Scalastyle marks the indentation of the first argument of all case classes that are split on multiple lines as wrong. case class Theme( id: String, <-- "Use correct indentation" name: String, start: Long ) This is my…
spydon
  • 9,372
  • 6
  • 33
  • 63