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

--disable-uncorrectable option does not insert todo comment as expected for multiline case #11706

Closed
KessaPassa opened this issue Mar 17, 2023 · 1 comment · Fixed by #11707
Closed
Labels

Comments

@KessaPassa
Copy link
Contributor

thank you for the fix to #11701
but, another issue similar to #11685 is there.

Expected behavior

Rubocop should process

ARRAY = %w[
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
].freeze

as

# rubocop:todo Layout/LineLength
ARRAY = %w[
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
].freeze
# rubocop:enable Layout/LineLength

for "--disable-uncorrectable" option

Actual behavior

it become infinite loop and I got

# rubocop:todo Metrics/CollectionLiteralLength
ARRAY = %w[
  # rubocop:todo Layout/LineLength
  # rubocop:enable Layout/LineLength
  # rubocop:enable Layout/LineLength
  ...
  # rubocop:todo Layout/LineLength
  # rubocop:todo Layout/LineLength
  # rubocop:enable Layout/LineLength
  # rubocop:todo Layout/LineLength
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
# rubocop:enable Layout/LineLength
  # rubocop:todo Layout/LineLength
# rubocop:enable Layout/LineLength
  ...
# rubocop:enable Layout/LineLength
  # rubocop:todo Layout/LineLength
  # rubocop:todo Layout/LineLength
  # rubocop:enable Layout/LineLength
].freeze
# rubocop:enable Metrics/CollectionLiteralLength

Steps to reproduce the problem

  1. create test_case.rb
  2. create.rubocop.yml
  3. run bundle exec rubocop -A --disable-uncorrectable test_case.rb

test_case.rb

ARRAY = %w[
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
].freeze

.rubocop.yml

Layout/LineLength:
  Max: 30

RuboCop version

This happens with HEAD of master (4346f8e)

$ [bundle exec] rubocop -V
1.48.1 (using Parser 3.2.1.1, rubocop-ast 1.27.0, running on ruby 3.0.5) [x86_64-darwin22]
  - rubocop-performance 1.16.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.19.0
@koic koic added the bug label Mar 17, 2023
@nobuyo
Copy link
Contributor

nobuyo commented Mar 17, 2023

Ahh I probably made a mistake.
I think I should have used overlaps? instead of crossing? here:

percent_array.map(&:source_range).find { |range| range.crossing?(offense_range) }

nobuyo added a commit to nobuyo/rubocop that referenced this issue Mar 17, 2023
…option and there is a multi-line percent array violates `Layout/LineLength`
koic added a commit that referenced this issue Mar 17, 2023
…line

[Fix #11706] Fix infinite loop when `--disable-uncorrectable` option and there is a multi-line percent array violates `Layout/LineLength`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants