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

Improve offense message for RSpec/IndexedLet #1953

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Aug 26, 2024

Ran into this offense and thought:

Where exactly does my name contain "index"?

Of course I got it eventually but I had to look up docs online. I believe this message format is more clear.


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

Ran into this offense and thought:
> Where exactly does my name contain "index"?

I believe this message format is more clear.
@Earlopain Earlopain requested a review from a team as a code owner August 26, 2024 19:35
@@ -48,8 +48,8 @@ class IndexedLet < Base
include AllowedIdentifiers
include AllowedPattern

MSG = 'This `let` statement uses index in its name. Please give it ' \
'a meaningful name.'
MSG = 'This `let` statement uses `%<index>s` in its name. ' \
Copy link
Member

Choose a reason for hiding this comment

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

Should we keep the work “index” eg “uses 3 index in its name”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

index doesn't seem like the right word to use. I know the cop is called IndexedLet but I wonder if that is a misnomer, NumberedLet (or similar) seems more accurate to what it does.

Personally I would leave it as is but overall not that important to me if you want it changed. Let me know.

Copy link
Member

@ydah ydah left a comment

Choose a reason for hiding this comment

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

Thank you!

@pirj pirj merged commit 74d7837 into rubocop:master Aug 27, 2024
24 checks passed
@Earlopain Earlopain deleted the offense-message-indexed-let branch August 27, 2024 11:07
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.

4 participants