Continuation of #9499
Inputfoo = "hello world!" foo [ 6, 5] = "rubocop" fooCommand
$ rubocop -a --only Layout/SpaceBeforeBrackets foo.rb
Inspecting 1 file
F
Offenses:
foo.rb:2:4: C: [Corrected] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
foo [ 6, 5] = "rubocop"
^^^^^^^^
foo.rb:2:9: F: Lint/Syntax: unexpected token tRBRACK
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
foo 6, 5] = "rubocop"
^
1 file inspected, 2 offenses detected, 1 offense corrected
Output
foo = "hello world!" foo 6, 5] = "rubocop" foo
The code is now invalid:
ruby foo.rb foo.rb: --> foo.rb Unmatched `]', missing `[' ? > 1 foo = "hello world!" > 2 foo 6, 5] = "rubocop" foo.rb:2: syntax error, unexpected ']', expecting end-of-input (SyntaxError) foo 6, 5] = "rubocop"RuboCop version
$ bundle exec rubocop -V
1.75.6 (using Parser 3.3.8.0, rubocop-ast 1.44.1, analyzing as Ruby 2.7, running on ruby 3.2.5) [x86_64-darwin23]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4