Skip to content

Commit

Permalink
Merge pull request rubocop#13559 from davidrunger/false-positive-for-…
Browse files Browse the repository at this point in the history
…redundant-line-continuation

Fix `Style/RedundantLineContinuation` false positive on method definition argument
  • Loading branch information
koic authored Dec 9, 2024
2 parents afe639e + 74d31b9 commit 1826d56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#13559](https://github.com/rubocop/rubocop/pull/13559): Fix a false positive for `Style/RedundantLineContinuation` when a method definition is used as an argument for a method call. ([@davidrunger][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/redundant_line_continuation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class RedundantLineContinuation < Base
LINE_CONTINUATION_PATTERN = /(\\\n)/.freeze
ALLOWED_STRING_TOKENS = %i[tSTRING tSTRING_CONTENT].freeze
ARGUMENT_TYPES = %i[
kFALSE kNIL kSELF kTRUE tCONSTANT tCVAR tFLOAT tGVAR tIDENTIFIER tINTEGER tIVAR
kDEF kFALSE kNIL kSELF kTRUE tCONSTANT tCVAR tFLOAT tGVAR tIDENTIFIER tINTEGER tIVAR
tLBRACK tLCURLY tLPAREN_ARG tSTRING tSTRING_BEG tSYMBOL tXSTRING_BEG
].freeze
ARGUMENT_TAKING_FLOW_TOKEN_TYPES = %i[tIDENTIFIER kRETURN kBREAK kNEXT kYIELD].freeze
Expand Down
10 changes: 10 additions & 0 deletions spec/rubocop/cop/style/redundant_line_continuation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,16 @@ def do_something
RUBY
end

it 'does not register an offense for a line continuation with a method definition as a method argument' do
expect_no_offenses(<<~'RUBY')
class Foo
memoize \
def do_something
end
end
RUBY
end

it 'does not register an offense when line continuations with using && for comparison chaining' do
expect_no_offenses(<<~'RUBY')
foo == other.foo \
Expand Down

0 comments on commit 1826d56

Please sign in to comment.