You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Foo
def bar; end
def bar_bar # rubocop:disable Metrics/MethodLength
@bars.map do |b|
begin
b.foo
rescue A => e
e
end
end
end
end
All is fine if bar_bar is first method. So def bar; end is needed.
Running rubocop
$ rubocop -a
warning: parser/current is loading parser/ruby27, which recognizes
warning: 2.7.2-compliant syntax, but you are running 2.7.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Inspecting 1 file
E
Offenses:
foo.rb:1:1: E: Lint/Syntax: class definition in method body
(Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
class Foo
^^^^^
foo.rb:1:1: C: Style/Documentation: Missing top-level class documentation comment.
class Foo
^^^^^
foo.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
class Foo
^
foo.rb:4:15: W: [Corrected] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/MethodLength.
def bar_bar # rubocop:disable Metrics/MethodLength
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
foo.rb:4:19: E: Lint/Syntax: formal argument cannot be an instance variable
(Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
def bar_bar @bars.map do |b|
^^^^^
1 file inspected, 5 offenses detected, 1 offense corrected, 1 more offense can be corrected with `rubocop -A`
Diff between actual result and expected
diff --git a/foo.rb b/foo.rb
index a421fb2..d09747d 100644
--- a/foo.rb
+++ b/foo.rb
@@ -1,7 +1,8 @@
class Foo
def bar; end
- def bar_bar @bars.map do |b|
+ def bar_bar
+ @bars.map do |b|
begin
b.foo
rescue A => e
The text was updated successfully, but these errors were encountered:
…opDisableDirective`
Fixesrubocop#9298.
This PR fixes an incorrect auto-correct for `Lint/RedundantCopDisableDirective`
when there is a blank line before inline comment.
Testfiles
::::::::::::::
.rubocop.yml
::::::::::::::
::::::::::::::
foo.rb
::::::::::::::
All is fine if bar_bar is first method. So
def bar; end
is needed.Running rubocop
$ rubocop -a
Diff between actual result and expected
The text was updated successfully, but these errors were encountered: