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 #9373]Fix indentation style tabs infinite loop #9377

Closed
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.md
Expand Up @@ -5366,3 +5366,4 @@
[@ohbarye]: https://github.com/ohbarye
[@magneland]: https://github.com/magneland
[@k-karen]: https://github.com/k-karen
[@joeyparis]: https://github.com/joeyparis
1 change: 1 addition & 0 deletions changelog/fix_indentation_style_tabs_infinite_loop.md
@@ -0,0 +1 @@
* [#9373](https://github.com/rubocop-hq/rubocop/issues/9373): Fix Identation/Style infinite loop when its IdentationWidth attribute is set to anything but 1. ([@joeyparis][])
7 changes: 6 additions & 1 deletion lib/rubocop/cop/layout/indentation_style.rb
Expand Up @@ -6,6 +6,11 @@ module Layout
# This cop checks that the indentation method is consistent.
# Either tabs only or spaces only are used for indentation.
#
# The `IndentationWidth` attribute is ignored when `EnforcedStyle` is `tabs`.
#
# When `EnforcedStyle` is set to `tabs` it is recommended to also set
# `Layout/IndentationWidth`'s `Width` attribute to `1`.
#
# @example EnforcedStyle: spaces (default)
# # bad
# # This example uses a tab to indent bar.
Expand Down Expand Up @@ -82,7 +87,7 @@ def autocorrect_lambda_for_tabs(range)
def autocorrect_lambda_for_spaces(range)
lambda do |corrector|
corrector.replace(range, range.source.gsub(/\A\s+/) do |match|
"\t" * (match.size / configured_indentation_width)
"\t" * match.size
end)
end
end
Expand Down