Skip to content

gracefully ignore projects with unsupported binary version #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ object ScalafixPlugin extends AutoPlugin {
def scalafixConfigSettings(config: Configuration): Seq[Def.Setting[?]] =
inConfig(config)(
relaxScalacOptionsConfigSettings ++ Seq(
config / scalafix / skip := (config / scalafix / skip).value ||
Seq("2.10", "2.11").contains(scalaBinaryVersion.value),
scalafix := {
// force evaluation of keys looked up in the same scope (config) within
// dynamic tasks to workaround https://github.com/sbt/sbt/issues/5647
Expand Down Expand Up @@ -502,7 +504,14 @@ object ScalafixPlugin extends AutoPlugin {
}
}
}
task.tag(Scalafix)
Def.taskDyn {
if (!(config / scalafix / skip).value)
task.tag(Scalafix)
else
Def.task {
(config / scalafix / streams).value.log.info("Skipping scalafix")
}
}
}

private def scalafixSyntactic(
Expand Down
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-scalafix/skip/.scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rules = [DisableSyntax]
DisableSyntax.noNulls = true
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-scalafix/skip/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resolvers += Resolver.sonatypeRepo("public")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % sys.props("plugin.version"))
3 changes: 3 additions & 0 deletions src/sbt-test/sbt-scalafix/skip/src/main/scala/Null1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Null1 {
println(null)
}
3 changes: 3 additions & 0 deletions src/sbt-test/sbt-scalafix/skip/src/test/scala/Null2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Null2 {
println(null)
}
41 changes: 41 additions & 0 deletions src/sbt-test/sbt-scalafix/skip/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-> scalafix
-> Test / scalafix
-> scalafixAll

##############################
# Project level
##############################
> set skip := true

> scalafix
> Test / scalafix
> scalafixAll

> set skip := false

##############################
# Task level
##############################
> set scalafix / skip := true

> scalafix
> Test / scalafix
> scalafixAll

> set scalafix / skip := false

##############################
# Config / Task level
##############################
> set Test / scalafix / skip := true

-> scalafix
> Test / scalafix
-> scalafixAll

> set Compile / skip := true

> scalafix
> Test / scalafix
> scalafixAll

5 changes: 4 additions & 1 deletion src/sbt-test/skip-sbt1.4/scalafixEnable/test
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
# check that we can run a semantic rule against a Scala 3 dialect source file
-> scala3 / scalafix --check SemanticRule
> scala3 / scalafix SemanticRule
> scala3 / scalafix --check SemanticRule
> scala3 / scalafix --check SemanticRule

# check that a global, aggregating scalafix is safe as unsupported projects are ignored
> scalafix