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 #11706] Fix infinite loop when --disable-uncorrectable option and there is a multi-line percent array violates Layout/LineLength #11707

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

nobuyo
Copy link
Contributor

@nobuyo nobuyo commented Mar 17, 2023

Fixes #11706, follows up #11701.


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.

create_file('.rubocop.yml', <<~YAML)
Layout/LineLength:
Max: 30
YAML
Copy link
Member

@koic koic Mar 17, 2023

Choose a reason for hiding this comment

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

This create_file is redundant with L265-L268. Can you remove this create_file and move the L265-L268 create_file to under L263 and put it in before block?

diff --git a/spec/rubocop/cli/disable_uncorrectable_spec.rb b/spec/rubocop/cli/disable_uncorrectable_spec.rb
index b1d42a469..e2003225b 100644
--- a/spec/rubocop/cli/disable_uncorrectable_spec.rb
+++ b/spec/rubocop/cli/disable_uncorrectable_spec.rb
@@ -261,11 +261,14 @@ RSpec.describe 'RuboCop::CLI --disable-uncorrectable', :isolated_environment do
       end

       context 'and the offense is inside a percent array' do
-        it 'adds before-and-after disable statement around the percent array' do
+        before do
           create_file('.rubocop.yml', <<~YAML)
             Layout/LineLength:
               Max: 30
           YAML
+        end
+
+        it 'adds before-and-after disable statement around the percent array' do
           create_file('example.rb', <<~RUBY)
             # frozen_string_literal: true

@@ -284,10 +287,6 @@ RSpec.describe 'RuboCop::CLI --disable-uncorrectable', :isolated_environment do
         end

         it 'adds before-and-after disable statement around the multi-line percent array' do
-          create_file('.rubocop.yml', <<~YAML)
-            Layout/LineLength:
-              Max: 30
-          YAML
           create_file('example.rb', <<~RUBY)
             # frozen_string_literal: true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

…option and there is a multi-line percent array violates `Layout/LineLength`
@nobuyo nobuyo force-pushed the fix-disable-uncorrectable-multiline branch from c3fb008 to 9150b4a Compare March 17, 2023 17:14
@nobuyo nobuyo requested a review from koic March 17, 2023 17:16
@koic koic merged commit 7dd56dd into rubocop:master Mar 17, 2023
@koic
Copy link
Member

koic commented Mar 17, 2023

Thanks!

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.

--disable-uncorrectable option does not insert todo comment as expected for multiline case
2 participants