If I have
puts (1 + 2) / 3
This rule fires. It should check that the ) is actually the last character before yelling at me.
Sorry, what is the (undesired) output of RC here?
@alexdowad
$ rubocop -D /tmp/a.rb
Inspecting 1 file
W
Offenses:
/tmp/a.rb:1:5: W: Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
puts (1 + 2) / 3
^
1 file inspected, 1 offense detected
From the tests for that cop:
it 'registers an offense for math expression' do
inspect_source(cop, 'puts (2 + 3) * 4')
expect(cop.offenses.size).to eq(1)
end
It appears that this is the desired behavior. Please either use another set of parens to disambiguate, or disable the cop.
This can be closed.
This is pretty unexpected. We don't use parenthesis for single arg method calls here. What is the protocol, to ask the cop author?
What is the protocol, to ask the cop author?
I don't know how to answer that question. You said "it should check...", which implied that the cop was buggy. Investigation revealed that it's not buggy; it is functioning as its author intended.
Now, if you disagree with the style choices which the cop author made and want to recommend something else, that can also be discussed. @jonas054, as you are the original author, do you have anything to say?
For Ruby 1.9 you get this warning from ruby -wc, but in later versions it no longer warns.
For me it makes sense in the general case (puts aside) to warn that func (a + b) / c means func((a + b) / c) and not func(a + b) / c.
...In other words: working as desired. Disable cop if you don't like it.