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 #11685] Fix incorrect directive comment insertion when percent array violates Layout/LineLength cop #11701

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

nobuyo
Copy link
Contributor

@nobuyo nobuyo commented Mar 14, 2023

Fixes #11685.

The problem was that directive comments were inserted inside percent literals and thus had no effect.
So I've added a condition to detect percent array as well as heredoc.

ARRAY = %i[
# rubocop:todo Layout/LineLength <---- 💥 
AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBB].freeze

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.

RUBY
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

IMHO, mock testing is naive and should be used as little as possible. Can you replace it with cli/autocorrect_spec.rb instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the test to spec/rubocop/cli/disable_uncorrectable_spec.rb (it's more appropriate I think)

@nobuyo nobuyo force-pushed the disable-uncorrectable-and-percent-array branch 3 times, most recently from 25540c9 to ae532a4 Compare March 16, 2023 14:08
@nobuyo nobuyo requested a review from koic March 16, 2023 14:37
…rcent array violates `Layout/LineLength` cop

Update lib/rubocop/cop/autocorrect_logic.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
@nobuyo nobuyo force-pushed the disable-uncorrectable-and-percent-array branch from 32170ac to adc392a Compare March 17, 2023 03:30
@nobuyo nobuyo requested a review from koic March 17, 2023 03:35
@koic koic merged commit 4346f8e 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
2 participants