Skip to content

Commit 8a971be

Browse files
committed
Add scalafix
1 parent ae0434c commit 8a971be

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ jobs:
1111
- uses: actions/[email protected]
1212
with:
1313
fetch-depth: 0
14+
- name: 'Linter: Scalafix checks'
15+
run: sbt "scalafixAll --check"
1416
- uses: olafurpg/setup-scala@v10
1517
- run: sbt test scripted publishLocal

.scalafix.conf

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
rules = [
2+
DisableSyntax, # Disables some constructs that make no semantic sense like `final val`
3+
ProcedureSyntax, # Procedure syntax in Scala is always discouraged
4+
NoValInForComprehension, # `val` in for comprehensions are deprecated and shouldn't be used
5+
NoAutoTupling, # Avoids the automatic tupling in parameters
6+
RemoveUnused, # Removes unused elements
7+
LeakingImplicitClassVal, # This rule adds the private access modifier on the field of implicit value classes in order to prevent direct access.
8+
OrganizeImports # Organizes imports and removes unused ones
9+
]
10+
11+
ExplicitResultTypes.memberKind = [Def, Val, Var]
12+
ExplicitResultTypes.memberVisibility = [Public, Protected]
13+
ExplicitResultTypes.skipSimpleDefinitions = ['Lit', 'Term.New', 'Term.Ref']
14+
ExplicitResultTypes.fatalWarnings = true
15+
DisableSyntax.noReturns = true
16+
DisableSyntax.noWhileLoops = true
17+
DisableSyntax.noXml = true
18+
DisableSyntax.noFinalVal = true
19+
DisableSyntax.noFinalize = true
20+
DisableSyntax.noValPatterns = true
21+
RemoveUnused.imports = false # The plugin organize imports removes unused and clashes with this
22+
OrganizeImports {
23+
groupedImports = Merge
24+
groups = [
25+
"*"
26+
"java."
27+
"scala."
28+
"re:javax?\\."
29+
] # Reasoning for this config is to keep the more business related imports at the top, while language imports are on the bottom
30+
}

build.sbt

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sbt.Keys.{semanticdbEnabled, semanticdbVersion}
2+
13
sbtPlugin := true
24

35
organization := "net.bzzt"
@@ -41,3 +43,14 @@ scriptedLaunchOpts := {
4143
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
4244
}
4345
scriptedBufferLog := false
46+
47+
// scalafix specific settings
48+
inThisBuild(
49+
List(
50+
semanticdbEnabled := true,
51+
semanticdbVersion := scalafixSemanticdb.revision,
52+
scalacOptions ++= Seq(
53+
"-Ywarn-unused"
54+
)
55+
)
56+
)

project/plugins.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.30")
55
addSbtPlugin("net.bzzt" % "sbt-strict-scala-versions" % "0.0.1")
66

77
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
8+
9+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")

0 commit comments

Comments
 (0)