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 #10427] Style/For: Mark auto-correction as unsafe #10429

Merged
merged 1 commit into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/change_mark_style_for_as_unsafe.md
@@ -0,0 +1 @@
* [#10427](https://github.com/rubocop/rubocop/issues/10427): Mark `Style/For` as unsafe auto-correction. ([@issyl0][])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think, as a first time contributor, you need to add your name at the bottom of CHANGELOG.md. See the last bullet point on https://github.com/rubocop/rubocop/blob/master/CONTRIBUTING.md.

Copy link
Member

Choose a reason for hiding this comment

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

There is no need to manually update the CHANGELOG.md file as first time contributor name will be inserted automatically :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's great! So much automation going on that I haven't kept up with.

3 changes: 2 additions & 1 deletion config/default.yml
Expand Up @@ -3544,8 +3544,9 @@ Style/For:
Description: 'Checks use of for or each in multiline loops.'
StyleGuide: '#no-for-loops'
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.13'
VersionChanged: '0.59'
VersionChanged: '<<next>>'
EnforcedStyle: each
SupportedStyles:
- each
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/style/for.rb
Expand Up @@ -38,6 +38,10 @@ module Style
# end
# end
#
# @safety
# This cop's autocorrection is unsafe because the scope of
# variables is different between `each` and `for`.
#
class For < Base
include ConfigurableEnforcedStyle
include RangeHelp
Expand Down