-
Notifications
You must be signed in to change notification settings - Fork 43
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
improve --files CLI UX #378
Conversation
@@ -127,13 +127,6 @@ object ScalafixPlugin extends AutoPlugin { | |||
Invisible | |||
) | |||
|
|||
private val scalafixCompletions: SettingKey[ScalafixCompletions] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inlining this saves some setting keys (sbt-scalafix adds a lot...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caused a regression, see #405
@@ -1,2 +1,2 @@ | |||
rules = [DisableSyntax] | |||
rules = [DisableSyntax, RemoveUnused] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a semantic rule to trigger the "semanticdb not found" error from the original bug report
> scalafix -f=src/main/scala/OK.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented in this PR, thanks to the isAllowedPrefix
check on aggregated projects which makes sbt skip aggregated executions silently
-> ok_only / scalafixAll -f=ok_only/src/main/scala/OK.scala | ||
|
||
# Targeting valid files from a different project fails | ||
-> ok_only / scalafix -f=ok_and_ko/src/main/scala/OK.scala | ||
|
||
# Targeting valid files from a different configuration fails | ||
-> ok_only / Test / scalafix -f=ok_only/src/main/scala/OK.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented in this PR
371152c
to
e6d109e
Compare
loadedRules = () => scalafixInterfaceProvider.value().availableRules(), | ||
terminalWidth = Some(JLineAccess.terminalWidth), | ||
allowedTargetFilesPrefixes = | ||
(scalafix / unmanagedSourceDirectories).value.map(_.toPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't rely on unmanagedSources
here as
- we want to be able to target directories as well
- it's a task, not available at settings evaluation time anyway
To avoid getting false positive errors (missing SemanticDB in presence of semantic rules), scalafix executions with `--files` should not aggregate as they are by nature specific to a given project / Configuration. - prevent usage of scalafixAll --files - validate --files values against unmanagedSourceDirectories - allow accurate completions - avoid aggregated executions: since requested files are not valid outside the project on which the task input was crafted, sbt simply ignores the runs
e6d109e
to
32a9ff7
Compare
Fixes scalacenter/scalafix#1874
To avoid getting false positive errors (missing SemanticDB in presence of semantic rules), scalafix executions with
--files
should not aggregate as they are by nature specific to a given project / Configuration.scalafixAll --files
--files
values againstunmanagedSourceDirectories