-
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
caching: remove optimization bringing false positive cache hits #145
Conversation
@@ -216,6 +217,7 @@ $ exec chmod 000 src/main/scala/Valid.scala | |||
> scalafix --check ProcedureSyntax | |||
-> test:scalafix --check ProcedureSyntax | |||
> test:scalafix ProcedureSyntax | |||
> test:scalafix ProcedureSyntax |
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.
a second run is needed for the cache to converge since there is a rewrite involved
> set scalafixConfig := None | ||
$ mkdir src/test/scala | ||
$ copy-file files/ProcedureSyntax.scala src/test/scala/ToPatch.scala | ||
$ copy-file files/Valid.scala src/test/scala/Valid.scala | ||
# avoid rounding in mtime that could cause false negatives in `newer` | ||
$ sleep 1000 | ||
> test:scalafix ProcedureSyntax | ||
> test:scalafix ProcedureSyntax DisableSyntax |
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.
adding a second rule for exhibiting the scenario, even though behavior is the same no matter how many rules we have (but it might change one day)
If a file is patched during a scalafix run, it's not safe to assume that all rules observed the updated content of that file and thus can be skipped next time. It is if we have only one rule (which we could check) or if the patch is applied after the first rule (which we can't tell). For correctness, stamping should happen before rule execution.
$ newer src/test/scala/ToPatch.scala src/test/scala/Valid.scala | ||
$ exec chmod 000 src/test/scala/ToPatch.scala | ||
$ exec chmod 000 src/test/scala/Valid.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.
irrelevant to the assertion, it's just useful to assert above via newer
that ToPatch
was updated
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.
I'm not familiar enough with the sbt Tracked
API to review the actual fix, but thank you for the quick followup! 🙏
scalacenter/scalafix#1164 (comment)
If a file is patched during a scalafix run, it's not safe to assume that all rules observed the updated content of that file and thus can
be skipped next time. It is if we have only one rule (which we could check) or if the patch is applied after the first rule (which we can't tell). For correctness, stamping should happen before rule execution.