Skip to content

Commit

Permalink
run scalafix on Scala 3 sources
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Jan 30, 2024
1 parent 15497b7 commitc45e7bf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .scalafix.conf →.scalafix-scala2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ExplicitResultTypes {
OrganizeImports {
groupedImports = Explode
expandRelative = true
removeUnused=true#done already by RemoveUnused rule
removeUnused = true
groups = [
"re:javax?\\."
"scala."
Expand Down
15 changes: 15 additions & 0 deletions .scalafix-scala3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rules = [
OrganizeImports
]

OrganizeImports {
groupedImports = Explode
expandRelative = true
removeUnused = false
groups = [
"re:javax?\\."
"scala."
"scala.meta."
"*"
]
}
16 changes: 12 additions & 4 deletions project/ScalafixBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
importautoImport._

overridedefglobalSettings:Seq[Def.Setting[_]]=List(
excludeLintKeys+=scalafixConfig,//defined on projects where ScalafixPlugin is disabled
stableVersion:=(ThisBuild/version).value.replaceFirst("\\+.*",""),
resolvers++=
Resolver.sonatypeOssRepos("snapshots")++
Expand Down Expand Up @@ -330,16 +331,23 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {

privatedefconfigSettings:Seq[Def.Setting[_]]=List(
//Workaround for https://github /scalacenter/scalafix/issues/1592:
//effectively skip scalafix[All] if the scala binary version of the project
//does not match the scalafix one (which cannot be per-project as it must be
//defined on ThisBuild)
//effectively skip scalafix[All] on 2.x projects not matching scalafixScalaBinaryVersion
scalafix/unmanagedSources:={
valprev=(scalafix/unmanagedSources).value
if(scalaBinaryVersion.value==scalafixScalaBinaryVersion.value) {
if(
Seq(scalafixScalaBinaryVersion.value,"3")
.contains(scalaBinaryVersion.value)
) {
prev
}else{
Seq()
}
},
scalafixConfig:={
if(scalaBinaryVersion.value.startsWith("2"))
Some(file(".scalafix-scala2.conf"))
else
Some(file(".scalafix-scala3.conf"))
}
)

Expand Down

0 comments on commitc45e7bf

Please sign into comment.