parentheses-as-grouped-expression
What it does
Section titled “What it does”Reports a space between a method name and a ( that holds its only argument (puts (x)). A call whose argument goes on after the parentheses (puts (1 + 2) * 3) is not reported.
Why it matters
Section titled “Why it matters”Ruby reads the parentheses as grouping the argument, not as enclosing the arguments of the call. With one argument the result is the same, but the form changes meaning when the code is edited: puts (1 + 2).abs calls abs on the group inside the call, while puts(1 + 2).abs calls it on the result of puts.
To fix, remove the space before (.
Example
Section titled “Example”...raise StandardErrorfoo (1)foo (a ? b : c)foo(1)...Configuration
Section titled “Configuration”ruby: lint: rules: parentheses-as-grouped-expression: warn # off (default), warn, errorEnabled by the presets: ruby/rubocop.
Suppress one line with sudsy-disable-next-line parentheses-as-grouped-expression in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| rubocop | Lint/ParenthesesAsGroupedExpression |
full |