Skip to content

Commit

Permalink
Merge pull request #233 from bjaglin/excludeLintKeys
Browse files Browse the repository at this point in the history
ensure keys do not need to be silenced with excludeLintKeys
  • Loading branch information
bjaglin authored Jun 7, 2021
2 parents c0b389f + 7449df5 commit 9c35cdb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ object ScalafixPlugin extends AutoPlugin {
}
val scalafixResolvers: SettingKey[Seq[Repository]] =
settingKey[Seq[Repository]](
"Optional list of Maven/Ivy repositories to use for fetching custom rules."
"Optional list of Maven/Ivy repositories to use for fetching custom rules. " +
"Must be set in ThisBuild."
)
val scalafixDependencies: SettingKey[Seq[ModuleID]] =
settingKey[Seq[ModuleID]](
"Optional list of custom rules to install from Maven Central. " +
"This setting is read from the global scope so it only needs to be defined once in the build."
"Must be set in ThisBuild."
)
val scalafixScalaBinaryVersion: SettingKey[String] =
settingKey[String](
"The Scala binary version used for scalafix execution. Defaults to 2.12. " +
s"Rules must be compiled against that binary version, or for advanced rules such as " +
s"ExplicitResultTypes which have a full cross-version, against the corresponding full" +
s"version that scalafix is built against."
"The Scala binary version used for scalafix execution. Must be set in ThisBuild. "
+ "Defaults to 2.12. Rules must be compiled against that binary version, or for "
+ "advanced rules such as ExplicitResultTypes which have a full cross-version, "
+ "against the corresponding full version that scalafix is built against."
)
val scalafixConfig: SettingKey[Option[File]] =
settingKey[Option[File]](
Expand All @@ -96,8 +97,12 @@ object ScalafixPlugin extends AutoPlugin {
inConfig(config)(
relaxScalacOptionsConfigSettings ++ Seq(
scalafix := {
// force detection of usage of `scalafixCaching` to workaround https://github.com/sbt/sbt/issues/5647
val _ = scalafixCaching.?.value
// force evaluation of keys looked up in the same scope (config) within
// dynamic tasks to workaround https://github.com/sbt/sbt/issues/5647
val _ = Seq(
scalafixCaching.?.value,
scalafixConfig.?.value
)
scalafixInputTask(config).evaluated
},
compile := Def.taskDyn {
Expand Down
19 changes: 19 additions & 0 deletions src/sbt-test/sbt-1.4/build-lint/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ThisBuild / scalafixDependencies := Nil
ThisBuild / scalafixResolvers := Nil
ThisBuild / scalafixScalaBinaryVersion := "2.12"
scalafixCaching := false
scalafixConfig := None
scalafixOnCompile := false

lazy val checkLintWarns = taskKey[Unit]("")
checkLintWarns := {
// https://github.com/sbt/sbt/blob/v1.4.9/sbt/src/sbt-test/project/lint/build.sbt
val state = Keys.state.value
val includeKeys =
(Global / includeLintKeys).value.map(_.scopedKey.key.label)
val excludeKeys =
(Global / excludeLintKeys).value.map(_.scopedKey.key.label)
val result =
sbt.internal.LintUnused.lintUnused(state, includeKeys, excludeKeys)
assert(result.size == 0)
}
1 change: 1 addition & 0 deletions src/sbt-test/sbt-1.4/build-lint/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.4.9
2 changes: 2 additions & 0 deletions src/sbt-test/sbt-1.4/build-lint/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"))
1 change: 1 addition & 0 deletions src/sbt-test/sbt-1.4/build-lint/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> checkLintWarns

0 comments on commit 9c35cdb

Please sign in to comment.