Skip to content
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

only warn when loading rules built with newer core #1588

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

bjaglin
Copy link
Collaborator

@bjaglin bjaglin commented Apr 4, 2022

Follow-up of #1565 (c4c1f1e#r69611050)

The risk for incompatibility is relatively low and upgrading Scalafix
is not always trivial depending on the client.
throw new ScalafixException(
s"Scalafix version ${Versions.nightly} cannot load the registered external rules, " +
s"please upgrade to ${dependency.getVersion} or later"
case TemptativeUp(compatibleRunWith) =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to clarify: this is code that will be triggered once external rules built against 0.10.1 and later are available

@bjaglin bjaglin requested a review from mlachkar April 4, 2022 21:22
@bjaglin bjaglin marked this pull request as ready for review April 4, 2022 21:22
@mlachkar
Copy link
Collaborator

mlachkar commented Apr 5, 2022

When we are going to publish 0.10.0, most external rules will be in 0.9.x , which will trigger the warn message of Tentative.Down.
Usually users that upgrade are the one that uses scala steward, so maybe the warn message won't be that visible if the CI is green.
Do we expect people not to upgrade to this version, but the rule authors to use this version to publish their rules ?

Comment on lines 19 to +22
- Running a rule built against a more recent X.Y or 0.Y.Z version of Scalafix
is not possible. In that case, a `ScalafixException` is raised when resolving
the rules(s) artifact(s).
is also a potential source of incompatibility. In that case, a warning
calling the user to upgrade Scalafix is issued when resolving the rules(s)
artifact(s).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this case easier to deal with than using a more recent rule.
The second requires rule author to publish a new version of their rule for each major version. In the other hand, we don't publish a major version very often!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second requires rule author to publish a new version of their rule for each major version

With this PR and the exception turned warning, it encourages them (since they will get report from users complaining about warnings, as discussed in #1588 (comment)) but does not require them.

Comment on lines +105 to +109
args.out.println(
s"""Loading external rule(s) built against a recent version of Scalafix (${dependency.getVersion}).
|This might not be a problem, but in case you run into unexpected behavior, you
|should upgrade Scalafix to ${compatibleRunWith}.
""".stripMargin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warn messages are super clear!
We can definitely turn that to an exception if many users complains that with scalafix 0.10.x, rules in 0.10.x x>0, it breaks. It would mean we don't pay too much attention to warn messages and in this case an exception is better.

Copy link
Collaborator Author

@bjaglin bjaglin Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warn messages are super clear!

Thanks, I spent a lot of time on them trying to get the right tone and making them actionnable.

We can definitely turn that to an exception if many users complains that with scalafix 0.10.x, rules in 0.10.x x>0, it breaks

What do you mean? 0.10.x runtimes will already be in the wild. we can't retroactively turn the warning into an exception.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean, we can still turn it into an exception in 0.10.5 for example, if we think a warning is not enough. I don't know if it's ok to that.

This message is only displayed when we have a tentativeUp starting 0.10.0.
The only case will be: A rule is published with 0.10.1 and the user has upgraded the rule, but not the scalafix version which is still 0.10.0.
Maybe throwing an exception is ok in that case.

Copy link
Collaborator Author

@bjaglin bjaglin Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean, we can still turn it into an exception in 0.10.5 for example, if we think a warning is not enough. I don't know if it's ok to that.

We can, but we would want to be more verbose in case 0.10.5 (or 0.11.0) brings silent changes important enough to prevent users to use an earlier version to run rules built/tested against it - however, it would be too late as 0.10.4 and earlier are out!

Copy link
Collaborator Author

@bjaglin bjaglin Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only case will be: A rule is published with 0.10.1 and the user has upgraded the rule, but not the scalafix version which is still 0.10.0.
Maybe throwing an exception is ok in that case, this PR changes this.

That's the current state on master/RC1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, let's for go for warn now. We can revisit for 1.x, maybe with an exception if build is newer by major or minor only, keeping a warn for patch diff.

@bjaglin
Copy link
Collaborator Author

bjaglin commented Apr 5, 2022

When we are going to publish 0.10.0, most external rules will be in 0.9.x , which will trigger the warn message of Tentative.Down.

Indeed, that's what I tried to explain in the release notes. I updated the message in the draft https://github.com/scalacenter/scalafix/releases/tag/untagged-7be1f5cfc653f2fefbfc to reflect the changes in this PR.

Do we expect people not to upgrade to this version, but the rule authors to use this version to publish their rules ?

With or without Steward, it's likely that people first upgrade sbt-scalafix (and other clients, as I opened PR for them to target 0.10.0 as early as possible) since rules will lag a bit behind, so they will get a warning. The value of the warning is that it will encourage rule authors to build against 0.10.x, so that we can potentially drop support for 0.9.x-built rules in 0.11.x or 1.x. (#1546 does the job but is hacky).

@bjaglin
Copy link
Collaborator Author

bjaglin commented Apr 5, 2022

@tgodzik it might be hard to follow the various discussions, but your feedback would be welcome here (with both your Metals and scalameta hat).

@mlachkar
Copy link
Collaborator

mlachkar commented Apr 5, 2022

I think @tgodzik is on vacation, but maybe we can have @ckipp01 opinion. Thanks in advance!

@bjaglin
Copy link
Collaborator Author

bjaglin commented Apr 5, 2022

I think @tgodzik is on vacation, but maybe we can have @ckipp01 opinion. Thanks in advance!

On the metals front, my (unchecked) assumption is that a given metals release pins both scalafix & the organize import rule, in which case versioning/compatibility is not a concern. If that's not the case (user-defined rules?), then it might be worth looking at how/if metals would handle warnings.

@mlachkar
Copy link
Collaborator

mlachkar commented Apr 5, 2022

So on metals, your assumption is correct.
Users can't define yet their rules that can be run through metals.

@ckipp01
Copy link
Member

ckipp01 commented Apr 5, 2022

I think @tgodzik is on vacation, but maybe we can have @ckipp01 opinion. Thanks in advance!

On the metals front, my (unchecked) assumption is that a given metals release pins both scalafix & the organize import rule, in which case versioning/compatibility is not a concern. If that's not the case (user-defined rules?), then it might be worth looking at how/if metals would handle warnings.

You're correct, we have both of those pinned, so if I'm following this all correctly this shouldn't impact stuff at all since the only external rule we're implemented with is the organize imports one. In the future if we ever add the functionality to run user-defined rules, then we'll cross that bridge when we get there 😆

@bjaglin bjaglin merged commit 3d79528 into scalacenter:main Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants