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 #11685

Closed
KessaPassa opened this issue Mar 10, 2023 · 0 comments · Fixed by #11701
Closed

--disable-uncorrectable option does not insert todo comment as expected #11685

KessaPassa opened this issue Mar 10, 2023 · 0 comments · Fixed by #11701

Comments

@KessaPassa
Copy link
Contributor

Expected behavior

Rubocop should process

ARRAY = %w[AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBB].freeze

as

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

for "--disable-uncorrectable" option

Actual behavior

it become infinite loop and I got

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
AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBB
# 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

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[AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBB].freeze

.rubocop.yml

Layout/LineLength:
  Max: 30

RuboCop version

This happens with HEAD of master (e74bed3)

$ [bundle exec] rubocop -V
1.46.0 (using Parser 3.2.1.1, rubocop-ast 1.26.0, running on ruby 2.7.6) [x86_64-darwin19]
  - rubocop-performance 1.16.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.18.1

This happens with ruby 3.1.2 too.

@KessaPassa KessaPassa changed the title --disable-uncorrectable option does not insert todo comment as expected. --disable-uncorrectable option does not insert todo comment as expected Mar 10, 2023
nobuyo added a commit to nobuyo/rubocop that referenced this issue Mar 17, 2023
…rcent array violates `Layout/LineLength` cop

Update lib/rubocop/cop/autocorrect_logic.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
koic added a commit that referenced this issue Mar 17, 2023
…nt-array

[Fix #11685] Fix incorrect directive comment insertion when percent array violates `Layout/LineLength` cop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant