Skip to content

Commit

Permalink
Update rubocop to 1.55.1 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 codeclimate#357).
- General bundle update.
- Updated docs.
  • Loading branch information
BrianHawley committed Jul 31, 2023
1 parent 95784bc commit 39b5890
Show file tree
Hide file tree
Showing 51 changed files with 465 additions and 134 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.55.1", 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
62 changes: 26 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.4.3)
activesupport (7.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -10,24 +10,25 @@ GEM
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.19.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 +38,56 @@ 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.55.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 (~> 1.41)
rubocop-factory_bot (2.22.0)
rubocop-factory_bot (2.23.1)
rubocop (~> 1.33)
rubocop-graphql (1.1.1)
rubocop-graphql (1.3.0)
rubocop (>= 0.87, < 2)
rubocop-i18n (3.0.0)
rubocop (~> 1.0)
rubocop-minitest (0.31.0)
rubocop (>= 1.39, < 2.0)
rubocop-performance (1.16.0)
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.19.1)
rubocop-rails (2.20.2)
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.23.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-shopify (2.14.0)
rubocop (~> 1.51)
rubocop-sorbet (0.7.0)
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.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
Expand All @@ -110,7 +101,7 @@ DEPENDENCIES
pry
rake
rspec
rubocop (= 1.50.2)
rubocop (= 1.55.1)
rubocop-graphql
rubocop-i18n
rubocop-minitest
Expand All @@ -122,8 +113,7 @@ DEPENDENCIES
rubocop-shopify
rubocop-sorbet
rubocop-thread_safety
standard (>= 1.0)
test-prof

BUNDLED WITH
2.1.4
2.4.10
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
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
25 changes: 25 additions & 0 deletions config/contents/lint/missing_super.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ because in some cases it makes sense to overtake what is considered a
missing method. In other cases, the theoretical ideal handling could be
challenging or verbose for no actual gain.

Autocorrection is not supported because the position of `super` cannot be
determined automatically.

`Object` and `BasicObject` are allowed by this cop because of their
stateless nature. However, sometimes you might want to allow other parent
classes from this cop, for example in the case of an abstract class that is
not meant to be called with `super`. In those cases, you can use the
`AllowedParentClasses` option to specify which classes should be allowed
*in addition to* `Object` and `BasicObject`.

### Example:
# bad
class Employee < Person
Expand Down Expand Up @@ -51,3 +61,18 @@ challenging or verbose for no actual gain.
do_something
end
end

# good
class ClassWithNoParent
def initialize
do_something
end
end

### Example: AllowedParentClasses: [MyAbstractClass]
# good
class MyConcreteClass < MyAbstractClass
def initialize
do_something
end
end
23 changes: 23 additions & 0 deletions config/contents/lint/mixed_case_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Checks for mixed-case character ranges since they include likely unintended characters.

Offenses are registered for regexp character classes like `/[A-z]/`
as well as range objects like `('A'..'z')`.

NOTE: Range objects cannot be autocorrected.

### Safety:

The cop autocorrects regexp character classes
by replacing one character range with two: `A-z` becomes `A-Za-z`.
In most cases this is probably what was originally intended
but it changes the regexp to no longer match symbols it used to include.
For this reason, this cop's autocorrect is unsafe (it will
change the behavior of the code).

### Example:

# bad
r = /[A-z]/

# good
r = /[A-Za-z]/
4 changes: 2 additions & 2 deletions config/contents/lint/numbered_parameter_assignment.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Checks for uses of numbered parameter assignment.
It emulates the following warning in Ruby 2.7:

% ruby -ve '_1 = :value'
$ ruby -ve '_1 = :value'
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
-e:1: warning: `_1' is reserved for numbered parameter; consider another name

Assigning to a numbered parameter (from `_1` to `_9`) causes an error in Ruby 3.0.

% ruby -ve '_1 = :value'
$ ruby -ve '_1 = :value'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
-e:1: _1 is reserved for numbered parameter

Expand Down
1 change: 0 additions & 1 deletion config/contents/lint/ordered_magic_comments.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Checks the proper ordering of magic comments and whether
a magic comment is not placed before a shebang.

Expand Down
Loading

0 comments on commit 39b5890

Please sign in to comment.