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

[Fix #9713] Skip autocorrection for block_local_variables in Lint/UnusedBlockArgument #9714

Merged
merged 1 commit into from Apr 21, 2021

Conversation

tejasbubane
Copy link
Contributor

Not sure if there is a better solution. But I think this cop should restrict itself to arguments and not make corrections within block body as suggested in the issue.

Closes #9713


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.

Comment on lines 210 to 207
1.times do |index; x|
^ #{message}
x = 10
puts index
end
Copy link
Member

Choose a reason for hiding this comment

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

Why is this an offense? The block variable is used?

@koic
Copy link
Member

koic commented Apr 20, 2021

I agree with @dvandersluis's concern. The issue is a false positive when using a local variable defined outside the block as a block variable. It requires testing based on #9713 and fix to the false positive. Unfortunately, skipping auto-correction does not solve the issue 😢

@tejasbubane
Copy link
Contributor Author

@koic @dvandersluis This was an existing behaviour which I assumed was intentional because the variable assigned inside block is not really used.

@tejasbubane tejasbubane force-pushed the fix-9713 branch 3 times, most recently from 97e9080 to aec8232 Compare April 20, 2021 10:16
@tejasbubane
Copy link
Contributor Author

I have changed code to not register offense in this case.

Copy link
Member

@koic koic left a comment

Choose a reason for hiding this comment

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

This change looks good to me. Thank you!

@bbatsov bbatsov merged commit 28e11ec into rubocop:master Apr 21, 2021
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 21, 2021

Thanks!

@tejasbubane tejasbubane deleted the fix-9713 branch April 21, 2021 06: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.

Lint/UnusedBlockArgument: mishandles block local variables
4 participants