Skip to content

Commit

Permalink
Address Layout/SpaceInsideArrayLiteralBrackets offense for Rails 7.…
Browse files Browse the repository at this point in the history
…2 and Ruby 3.1 app

This commit addresses the following CI failure at the 7-2-stable branch
https://buildkite.com/rails/rails/builds/111646#019210c6-3574-468d-ad92-4263e0378d95/1118-1124

This failure only happens at the 7-2-stable branch using Ruby 3.1 because of the following reasons:

- `rubocop-rails-omakase` is enabled for newly created Rails application since Rails 7.2.0

- `error_highlight` needs to be installed explicitly only if `RUBY_VERSION < "3.2"`
https://github.com/rails/rails/blob/73e473e105ea17711776dd300389930a15204cf2/railties/lib/rails/generators/rails/app/templates/Gemfile.tt#L54-L60

- Rails main branch does not have this code because Rails 8 will bump the required Ruby version to higher one.
rails@dc96d29

This commit addresses the following failures.

```
$ ruby -v
ruby 3.1.5p252 (2024-04-23 revision 1945f8dc0e) [x86_64-linux]
$ cd railties
$ bin/test test/generators/app_generator_test.rb -n test_generated_files_have_no_rubocop_warnings
$ bin/test test/generators/app_generator_test.rb -n test_generated_files_have_no_rubocop_warnings
Run options: -n test_generated_files_have_no_rubocop_warnings --seed 58776

F

Failure:
AppGeneratorTest#test_generated_files_have_no_rubocop_warnings [test/generators/shared_generator_tests.rb:413]:
bin/rubocop did not exit successfully:
Inspecting 27 files
C..........................

Offenses:

Gemfile:50:49: C: [Correctable] Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
  gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
                                                ^
Gemfile:50:55: C: Layout/SpaceInsideArrayLiteralBrackets: Use space inside array brackets.
  gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
                                                      ^

27 files inspected, 2 offenses detected, 1 offense autocorrectable
.
Expected #<Process::Status: pid 782031 exit 1> to be success?.

bin/test test/generators/shared_generator_tests.rb:407

Finished in 2.008499s, 0.4979 runs/s, 0.4979 assertions/s.
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
$
```
  • Loading branch information
yahonda committed Sep 25, 2024
1 parent 73e473e commit 9a53f0c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ group :development do
<%- if RUBY_VERSION < "3.2" -%>

# Highlight the fine-grained location where an error occurred [https://github.com/ruby/error_highlight]
gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
gem "error_highlight", ">= 0.4.0", platforms: [ :ruby ]
<%- end -%>
end
<%- end -%>
Expand Down

0 comments on commit 9a53f0c

Please sign in to comment.