A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/9499 below:

Layout/SpaceBeforeBrackets generates invalid code · Issue #9499 · rubocop/rubocop · GitHub

Input
foo = "hello world!"
foo[  6, 5]  = "rubocop"
foo
Command
$ rubocop -a --only Layout/SpaceBeforeBrackets foo.rb
Inspecting 1 file
C

Offenses:

foo.rb:2:4: C: [Corrected] Layout/SpaceBeforeBrackets: Remove the space before the opening brackets.
foo[  6, 5]  = "rubocop"
   ^^

###Output

foo = "hello world!"
foo 6, 5]  = "rubocop"
foo

The code is now invalid:

ruby foo.rb 
foo.rb:2: syntax error, unexpected ']', expecting end-of-input
foo 6, 5]  = "rubocop"
RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

1.9.1 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-darwin19)

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