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

Make UselssAssertion autocorrect contextual #308

Closed

Conversation

Earlopain
Copy link
Contributor

This is an annoying autocorrect to happen while typing.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@koic
Copy link
Member

koic commented Apr 7, 2024

Hm, I don't see the use case for setting this cop to AutoCorrect: contextual.

@Earlopain
Copy link
Contributor Author

Here's how it goes for me usually

Screencast_20240407_173508.webm

@koic
Copy link
Member

koic commented Apr 7, 2024

Thank you for making the video. However, I didn't quite get it. Can you provide some additional explanation in text?

@Earlopain
Copy link
Contributor Author

Earlopain commented Apr 7, 2024

Sure, I can try. When I write tests I tend to do this:

assert_equal([], some_method)
# Expected: []
# Actual: ["foo", "bar"]

I let the tests run, get the data from the failure, and copy it over to the first argument to make it pass. With the autocorrect I have an extra step where I need to restore the intended assert_equal to make it work. I guess I could write anything else than [] but when I know it'll be an array I just do it automatically.

Hope that makes sense.

@andyw8
Copy link
Contributor

andyw8 commented Apr 7, 2024

I understand the annoyance for your workflow, but I think this shouldn't be marked as contextual. I think there would be many genuine occurrences that won't be caught until a full RuboCop check is run, e.g. after pushing to CI.

@koic
Copy link
Member

koic commented Apr 7, 2024

I agree with @andyw8. So, applying AutoCorrect: contextual for cases clearly written with unintended arguments would mean that most cops in RuboCop Minitest would no longer be AutoCorrect: always (default).
I will close this PR, but thank you for the video and the explanation.

@koic koic closed this Apr 7, 2024
@Earlopain Earlopain deleted the useless-assertion-contextual branch April 7, 2024 20:54
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.

None yet

3 participants