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

False positive for Style/RedundantArgument #12794

Closed
t-mario-y opened this issue Mar 15, 2024 · 0 comments · Fixed by #12812
Closed

False positive for Style/RedundantArgument #12794

t-mario-y opened this issue Mar 15, 2024 · 0 comments · Fixed by #12812
Labels

Comments

@t-mario-y
Copy link

t-mario-y commented Mar 15, 2024

Expected behavior

String#chompmethod for '\n' (single quoted) should not be affected by Style/RedundantArgument cop, because special treatment in this method is "\n" (double quoted).

Actual behavior

Single quoted '\n' is also detected offence after this commit: 8b3656d

Steps to reproduce the problem

Targetting example Ruby file like contains 'foo'.chomp('\n'):

bundle ex rubocop --only Style/RedundantArgument single_quote_chomp.rb

Result:

Inspecting 1 file
C

Offenses:

single_quote_chomp.rb:1:12: C: [Correctable] Style/RedundantArgument: Argument '\n' is redundant because it is implied by default.
'foo'.chomp('\n')
           ^^^^^^

RuboCop version

$ [bundle exec] rubocop -V
1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.1.4) [x86_64-linux]
  - rubocop-dependency 0.1.2
  - rubocop-factory_bot 2.25.1
  - rubocop-performance 1.20.2
  - rubocop-rails 2.24.0
  - rubocop-rspec 2.27.1
  - rubocop-sorbet 0.7.8
  - rubocop-thread_safety 0.5.1
@t-mario-y t-mario-y changed the title False positive of for Style/RedundantArgument False positive for Style/RedundantArgument Mar 15, 2024
@koic koic added the bug label Mar 15, 2024
koic added a commit to koic/rubocop that referenced this issue Mar 26, 2024
Fixes rubocop#12794.

This PR fixes false positives for `Style/RedundantArgument`
when when single-quoted strings for cntrl character.
koic added a commit that referenced this issue Mar 26, 2024
…undant_argument

[Fix #12794] Fix false positives for `Style/RedundantArgument`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants