Use this file and run latest rubocop against it:
https://github.com/airbrake/airbrake/blob/v7.1.0/lib/airbrake/capistrano/capistrano2.rb
No offence of the Layout/EmptyLinesAroundArguments cop
lib/airbrake/capistrano/capistrano2.rb:4:1: C: Layout/EmptyLinesAroundArguments: Empty line detected around arguments.
# rubocop:disable Metrics/AbcSize
^
lib/airbrake/capistrano/capistrano2.rb:7:1: C: Layout/EmptyLinesAroundArguments: Empty line detected around arguments.
after 'deploy', 'airbrake:deploy'
^
The offending lines are actually L18 & L21. I believe it's wrong to force me to format my strings how I want.
$ rubocop -V
0.52.0 (using Parser 2.4.0.2, running on ruby 2.4.2 x86_64-darwin16)
Kyrylo's example actually involves arguments, but I'm seeing a false positive that does not involve arguments.
module A
module B # <- offense on this line: "Empty line detected around arguments."
# .. 100 lines later ..
def c
d.
e(f).
# removing the blank line above fixes offense
g(h)
end
end
end
Here's a short bit of nonsense code that still gets the false positive. Removing any remaining part makes the warning go away.
(1..10).map do |number| # Rubocop complains about this line
next if number.even?
number
end.compact
Another false positive here.
A = [
1,
# comment
2
]
B = A + [
3,
4
]
$ rubocop -V
0.52.0 (using Parser 2.4.0.2, running on ruby 2.4.1 x86_64-darwin16)
$ rubocop --only Layout/EmptyLinesAroundArguments input.rb
[snip]
input.rb:3:1: C: Layout/EmptyLinesAroundArguments: Empty line detected around arguments.
# comment
^
Weirdly, deleting the assignment to B or the blank line after 3, or the A + portion fixes offense.
I tried #5231 but it didn't help.
We've got a lot of random false positive. Sometimes it's a class definition, sometimes it's a module, or an end or indentation space. Here's a few of them:
class InvoiceRetryWorker
^
module Dnsimple
^
# Some code comment
^
def call(notification)
^
RSpec.describe "..." do
^
rescue ActiveRecord::ActiveRecordError => e
^
let(:counter) {
^
^
It seems like location is reported incorrectly:
Rollbar.configure do |config|
# Without configuration, Rollbar is enabled in all environments.
# To disable in specific environments, set config.enabled=false.
config.enabled = Rails.env.in?(%w[production staging])
config.exception_level_filters.merge!(
'ActionController::Other' => 'ignore',
'ActionController::BadRequest' => 'ignore',
'ActionController::InvalidCrossOriginRequest' => 'ignore',
'ActionController::OtherCSRF' => 'ignore'
)
end
=>
config/initializers/rollbar.rb:4:1: C: Layout/EmptyLinesAroundArguments: Empty line detected around arguments.
I would agree with @printercu, I had the same issue, it would appear that it is the simply reporting the wrong location. It seems to give the offset within the block rather than the file.
@eamonn-webster & @printercu - You are absolutely right. I'm able to confirm with a variety of examples, and I see/understand the problem in the code. Working on a solution now.
I think I'm getting a false positive too for:
sh('script.py', error_callback: lambda { |result|
error = JSON.parse(result, symbolize_names: true)
error_text = error[:error]
UI.user_error!("Error: #{error_text}")
})
at line 4 using RuboCop 0.52.1.
@revolter - You are correct. The final fixes for this cop are unreleased. You can test it against rubocop master if you'd like, or hold off on enabling the cop until the next version. This scenario should now be accounted for though.
Ok, thanks for the quick update and confirmation!