-
Notifications
You must be signed in to change notification settings - Fork 113
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
Requalify strict violations #367
Conversation
…s for strict mode
…t mode violations
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 really like the idea here. The fact that strict mode will only fail after you run update and then run check
makes it a lot less useful, because most folks will run update
and assume everything is fine without running check, and then wait until CI fails to realize they are violating strict mode.
Failing during update makes a lot of sense to me, since it reduces the number and duration of feedback loops. I find the idea of a softer strict mode interesting. Allowing the violations to exist in the TODO file, but not permit new ones to be added with the tooling is definitely interesting. Technically this can be bypassed by updating TODO files by hand, but I think that's okay (since we're trying to create happy-path guard rails, rather than a 'barbed wire fence').
It feels like possibly an alternative to #365, cc @athieriot
#{offenses_formatter.show_offenses(offense_collection.errors)} | ||
✅ `package_todo.yml` has been updated. | ||
EOS | ||
if offense_collection.strict_mode_violations.any? |
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.
It looks like if there are any strict mode violations, we fail out immediately and do not make any changes to TODO files.
What do you think of instead making all the changes we can make when updating, but then if there are any strict mode violations, we inform the user and exit with a failure?
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 think your proposal makes more sense. I reworked the PR in ef4d6c6.
OffenseCollection does not update the package-todo for strict mode violations that it doesn't already know about (we need to add the entries already known to avoid stale violation errors).
This way, we can run the update_todo
command and it won't fail early, it will update what it can, it won't add entries that qualify as strict violation. And as suggested, the strict violation offenses are displayed and the exit code indicates a failure.
I can update the PR description tomorrow if that works for you?
I think what this PR proposes and what's in @athieriot's PR could be complementary. |
@@ -85,6 +90,12 @@ def outstanding_offenses | |||
|
|||
sig { params(offense: ReferenceOffense).returns(T::Boolean) } | |||
def already_listed?(offense) |
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 like this cleanup – already_listed?
was returning a boolean but also mutating data. Now it's two separate operations which is a lot more clean!
components/source/other/path.rb | ||
other message | ||
|
||
2 offenses detected |
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.
It feels like this message should say something about not being able to successfully add certain violations to the TODO list due to strict mode. Right now it's unclear why it wasn't added.
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.
You're right, I've amended the message to only include strict violations that are blocking for the update_todo
command to complete successfully and changed the final message to explain that something went wrong.
This looks good to me. @rafaelfranca do you have any feedback or are we good to merge and release? |
CLA needs to be signed before we merge this though. |
Ah, it was. |
What are you trying to accomplish?
This is a proposal to change how
strict_mode_violations
offenses are gathered and prevent theupdate_todo
from updating a package_todo.yml file with new violations once the strict mode is activated for a package.Currently the OffenseCollection class will only check whether an offense qualifies as a strict mode violation if it was already present in the file package_todo.yml, I think it should be up to the checker to determine whether offenses, known or unknown, qualify as strict mode violations.
Down the line, the goal would be to enable checkers to apply a 'less strict' mode where new violations cannot be added to the package_todo.yml file but violations that were written to the file before do not cause an error. This would be for packages where it is difficult to reach an empty package_todo.yml but we want to stop the bleeding.
What approach did you choose and why?
What should reviewers focus on?
Type of Change
Additional Release Notes
Update with the
update_todo
command of package_todo.yml would fail in cases where it would work todayChecklist