Skip to content

Commit

Permalink
Update rubocop to 1.56.3 and ruby to 3.2.2
Browse files Browse the repository at this point in the history
Ruby 2 is EOL, and can have trouble installnig on modern systems.

- Updated ruby in .ruby-version and Dockerfile.
- No need to install an old version of bundler in Dockerfile.
- Removed the standard gem (see #357).
- General bundle update.
- Updated docs.
  • Loading branch information
BrianHawley committed Sep 22, 2023
1 parent 95784bc commit 2190bc5
Show file tree
Hide file tree
Showing 58 changed files with 592 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.6
3.2.2
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ruby:2.7-alpine3.11
FROM ruby:3.2-alpine3.18

LABEL name="Ruby-2.7" \
LABEL name="Ruby-3.2" \
version="1.0"

WORKDIR /usr/src/app
Expand All @@ -10,7 +10,6 @@ RUN adduser -u 9000 -D app
COPY Gemfile Gemfile.lock /usr/src/app/

RUN apk add --update build-base git && \
gem install bundler -v 2.0.2 && \
bundle install --quiet -j 4 && \
chown -R app:app /usr/local/bundle && \
rm -fr ~/.gem ~/.bundle ~/.wh..gem && \
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source 'https://rubygems.org'
gem "activesupport", require: false
gem "parser"
gem "pry", require: false
gem "rubocop", "1.50.2", require: false
gem "rubocop", "1.56.3", require: false
gem "rubocop-i18n", require: false
gem "rubocop-graphql", require: false
gem "rubocop-minitest", require: false
Expand All @@ -17,7 +17,6 @@ gem "rubocop-sequel", require: false
gem "rubocop-shopify", require: false
gem "rubocop-sorbet", require: false
gem "rubocop-thread_safety", require: false
gem "standard", ">= 1.0", require: false
gem "test-prof", require: false

group :test do
Expand Down
72 changes: 32 additions & 40 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.4.3)
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
coderay (1.1.3)
concurrent-ruby (1.2.2)
diff-lcs (1.5.0)
i18n (1.13.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
lint_roller (1.0.0)
method_source (1.0.0)
minitest (5.18.0)
minitest (5.20.0)
parallel (1.23.0)
parser (3.2.2.1)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
rack (3.0.7)
racc (1.7.1)
rack (3.0.8)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.0)
rexml (3.2.5)
regexp_parser (2.8.1)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand All @@ -37,66 +39,57 @@ GEM
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.50.2)
rspec-support (3.12.1)
rubocop (1.56.3)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.0.0)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.1)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.22.0)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-graphql (1.1.1)
rubocop (>= 0.87, < 2)
rubocop-graphql (1.4.0)
rubocop (>= 0.90, < 2)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
rubocop-minitest (0.31.0)
rubocop-minitest (0.31.1)
rubocop (>= 1.39, < 2.0)
rubocop-performance (1.16.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.19.1)
rubocop-rails (2.21.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.22.0)
rubocop-rspec (2.24.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-sequel (0.3.4)
rubocop (~> 1.0)
rubocop-shopify (2.13.0)
rubocop (~> 1.50)
rubocop-sorbet (0.7.0)
rubocop-shopify (2.14.0)
rubocop (~> 1.51)
rubocop-sorbet (0.7.3)
rubocop (>= 0.90.0)
rubocop-thread_safety (0.5.1)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
standard (1.28.2)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50.2)
standard-custom (~> 1.0.0)
standard-performance (~> 1.0.1)
standard-custom (1.0.0)
lint_roller (~> 1.0)
standard-performance (1.0.1)
lint_roller (~> 1.0)
rubocop-performance (~> 1.16.0)
test-prof (1.2.1)
test-prof (1.2.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
Expand All @@ -110,7 +103,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 1.50.2)
rubocop (= 1.56.3)
rubocop-graphql
rubocop-i18n
rubocop-minitest
Expand All @@ -122,8 +115,7 @@ DEPENDENCIES
rubocop-shopify
rubocop-sorbet
rubocop-thread_safety
standard (>= 1.0)
test-prof

BUNDLED WITH
2.1.4
2.4.10
1 change: 1 addition & 0 deletions config/contents/bundler/duplicated_gem.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
A Gem's requirements should be listed only once in a Gemfile.

### Example:
# bad
gem 'rubocop'
Expand Down
51 changes: 51 additions & 0 deletions config/contents/bundler/duplicated_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
A Gem group, or a set of groups, should be listed only once in a Gemfile.

For example, if the values of `source`, `git`, `platforms`, or `path`
surrounding `group` are different, no offense will be registered:

[source,ruby]
-----
platforms :ruby do
group :default do
gem 'openssl'
end
end

platforms :jruby do
group :default do
gem 'jruby-openssl'
end
end
-----

### Example:
# bad
group :development do
gem 'rubocop'
end

group :development do
gem 'rubocop-rails'
end

# bad (same set of groups declared twice)
group :development, :test do
gem 'rubocop'
end

group :test, :development do
gem 'rspec'
end

# good
group :development do
gem 'rubocop'
end

group :development, :test do
gem 'rspec'
end

# good
gem 'rubocop', groups: [:development, :test]
gem 'rspec', groups: [:development, :test]
10 changes: 9 additions & 1 deletion config/contents/bundler/ordered_gems.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ Gems should be alphabetically sorted within groups.

gem 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
### Example: TreatCommentsAsGroupSeparators: true (default)
# good
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'

### Example: TreatCommentsAsGroupSeparators: false
# bad
# For code quality
gem 'rubocop'
# For tests
Expand Down
10 changes: 9 additions & 1 deletion config/contents/gemspec/ordered_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ Dependencies in the gemspec should be alphabetically sorted.

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
### Example: TreatCommentsAsGroupSeparators: true (default)
# good
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

### Example: TreatCommentsAsGroupSeparators: false
# bad
# For code quality
spec.add_dependency 'rubocop'
# For tests
Expand Down
8 changes: 8 additions & 0 deletions config/contents/layout/class_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ automatically.
- extend
```
### Safety:
Autocorrection is unsafe because class methods and module inclusion
can behave differently, based on which methods or constants have
already been defined.
Constants will only be moved when they are assigned with literals.
### Example:
# bad
# Expect extend be before constant
Expand Down
1 change: 0 additions & 1 deletion config/contents/layout/closing_heredoc_indentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Checks the indentation of here document closings.

### Example:
Expand Down
17 changes: 16 additions & 1 deletion config/contents/layout/empty_line_after_guard_clause.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
Enforces empty line after guard clause
Enforces empty line after guard clause.

This cop allows `# :nocov:` directive after guard clause because
SimpleCov excludes code from the coverage report by wrapping it in `# :nocov:`:

```ruby
def foo
# :nocov:
return if condition
# :nocov:
bar
end
```

Refer to SimpleCov's documentation for more details:
https://github.com/simplecov-ruby/simplecov#ignoringskipping-code

### Example:

Expand Down
4 changes: 2 additions & 2 deletions config/contents/layout/space_around_method_call_operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Checks method call operators to not have spaces around them.
foo &. bar
foo &. bar&. buzz
RuboCop:: Cop
RuboCop:: Cop:: Cop
RuboCop:: Cop:: Base
:: RuboCop::Cop

# good
Expand All @@ -26,5 +26,5 @@ Checks method call operators to not have spaces around them.
foo&.bar
foo&.bar&.buzz
RuboCop::Cop
RuboCop::Cop::Cop
RuboCop::Cop::Base
::RuboCop::Cop
1 change: 1 addition & 0 deletions config/contents/lint/duplicate_hash_key.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Checks for duplicated keys in hash literals.
This cop considers both primitive types and constants for the hash keys.

This cop mirrors a warning in Ruby 2.2.

Expand Down
7 changes: 3 additions & 4 deletions config/contents/lint/erb_new_arguments.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

This cop emulates the following Ruby warnings in Ruby 2.6.
Emulates the following Ruby warnings in Ruby 2.6.

```console
% cat example.rb
$ cat example.rb
ERB.new('hi', nil, '-', '@output_buffer')
% ruby -rerb example.rb
$ ruby -rerb example.rb
example.rb:1: warning: Passing safe_level with the 2nd argument of ERB.new is
deprecated. Do not use it, and specify other arguments as keyword arguments.
example.rb:1: warning: Passing trim_mode with the 3rd argument of ERB.new is
Expand Down
1 change: 0 additions & 1 deletion config/contents/lint/identity_comparison.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Prefer `equal?` over `==` when comparing `object_id`.

`Object#equal?` is provided to compare objects for identity, and in contrast
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0.

This cop checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0.
When an array of IO objects waiting for an exception (the third argument of `IO.select`)
is used as an argument, there is no alternative API, so offenses are not registered.

NOTE: When the method is successful the return value of `IO.select` is `[[IO]]`,
and the return value of `io.wait_readable` and `io.wait_writable` are `self`.
Expand Down
2 changes: 1 addition & 1 deletion config/contents/lint/lambda_without_literal_block.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Checks uses of lambda without a literal block.
It emulates the following warning in Ruby 3.0:

% ruby -vwe 'lambda(&proc {})'
$ ruby -vwe 'lambda(&proc {})'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
-e:1: warning: lambda without a literal block is deprecated; use the proc without
lambda instead
Expand Down
Loading

0 comments on commit 2190bc5

Please sign in to comment.