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
Using Rubocop 0.39.0 (using Parser 2.3.0.7, running on ruby 2.2.3 x86_64-darwin14) the following offenses/corrections are listed:
➜ /tmp rubocop -a foo.rb
Inspecting 1 file
C
Offenses:
foo.rb:1:16: C: [Corrected] Space missing after colon.
'a' == 'b' ? 1 :2
^
foo.rb:1:16: C: [Corrected] Operator : should be surrounded by a single space.
'a' == 'b' ? 1 : 2
^
foo.rb:1:16: C: [Corrected] Surrounding space missing for operator :.
'a' == 'b' ? 1 :2
^
foo.rb:1:17: C: [Corrected] Unnecessary spacing detected.
'a' == 'b' ? 1 : 2
^
1 file inspected, 4 offenses detected, 4 offenses corrected
Notice that the since both Style/SpaceAfterColon and Style/Style/SpaceAroundOperators logged and corrected offenses, Rubocop generated double spacing after the colon, which it then detected and corrected. Indeed the file is corrected properly:
➜ /tmp cat foo.rb
'a' == 'b' ? 1 : 2
I think Style/SpaceAfterColon should not handle spaces in a ternary operator, which would avoid the double reporting and too much correction.
The text was updated successfully, but these errors were encountered:
owst
added a commit
to owst/rubocop
that referenced
this issue
Apr 7, 2016
Both `Style/SpaceAfterColon` and `Style/SpaceAroundOperators` were
detecting the missing space after a colon in a ternary operator, this
led to redundant warnings and corrections. To fix, the ternary handling
from `Style/SpaceAfterColon` was removed.
Consider the following simple Ruby source file:
Using Rubocop
0.39.0 (using Parser 2.3.0.7, running on ruby 2.2.3 x86_64-darwin14)
the following offenses/corrections are listed:Notice that the since both
Style/SpaceAfterColon
andStyle/Style/SpaceAroundOperators
logged and corrected offenses, Rubocop generated double spacing after the colon, which it then detected and corrected. Indeed the file is corrected properly:I think
Style/SpaceAfterColon
should not handle spaces in a ternary operator, which would avoid the double reporting and too much correction.The text was updated successfully, but these errors were encountered: