Skip to content

Commit 762cd62

Browse files
authored
Support ruby 3.1 (#189)
**BREAKING**: Drop support for ruby 2.4 * Upgrade rubocop to version 1.22.0 * InvalidPredicateMatcher and CustomIncludeMethods are removed * Add dependencies on `rubocop-rails` and `rubocop-performance` Thanks @bmulholland and @RenzoMinelli
1 parent 1939a2f commit 762cd62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+834
-1258
lines changed

.github/workflows/rspec_rubocop.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@ jobs:
1818
strategy:
1919
matrix:
2020
include: # use bundler 2.3 for ruby versions < 2.6 (https://bundler.io/compatibility.html)
21-
- ruby-version: 2.4
22-
bundler-version: 2.3
2321
- ruby-version: 2.5
2422
bundler-version: 2.3
2523
- ruby-version: 2.6
2624
bundler-version: latest
2725
- ruby-version: 2.7
2826
bundler-version: latest
29-
# TODO: reenable tests against ruby 3.0 after upgrading base Rubocop version above 1.22.0,
30-
# thus correcting the syntax errors when running the Layout/BlockAlignment cop
31-
# https://github.com/airbnb/ruby/pull/189#discussion_r1101793307
32-
# - ruby-version: 3.0
33-
# bundler-version: latest
27+
- ruby-version: 3.0
28+
bundler-version: latest
29+
- ruby-version: 3.1
30+
bundler-version: latest
3431
steps:
3532
- uses: actions/checkout@v3
3633
- name: Set up Ruby

rubocop-airbnb/config/default.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ AllCops:
1515
- 'vendor/**/*'
1616
- Vagrantfile
1717
- Guardfile
18-
RSpec:
19-
Patterns:
20-
- _spec.rb
21-
- "(?:^|/)spec/"
22-
RSpec/FactoryBot:
23-
Patterns:
24-
- spec/factories/**/*.rb
25-
- features/support/factories/**/*.rb
2618

2719
# While Rubocop has released a bunch of new cops, not all of these cops have been evaluated as
2820
# part of this styleguide. To prevent new, unevaluated cops from imposing on this styleguide, we
@@ -33,6 +25,15 @@ AllCops:
3325
# https://github.com/rubocop/rubocop/blob/1e55b1aa5e4c5eaeccad5d61f08b7930ed6bc341/config/default.yml#L89-L101
3426
DisabledByDefault: true
3527

28+
RSpec:
29+
Include:
30+
- _spec.rb
31+
- "(?:^|/)spec/"
32+
RSpec/FactoryBot:
33+
Include:
34+
- spec/factories/**/*.rb
35+
- features/support/factories/**/*.rb
36+
3637
inherit_from:
3738
- './rubocop-airbnb.yml'
3839
- './rubocop-bundler.yml'

rubocop-airbnb/config/rubocop-performance.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
require:
2+
- rubocop-performance
3+
14
Performance/Caller:
25
Enabled: false
36

rubocop-airbnb/config/rubocop-rails.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
require:
2+
- rubocop-rails
3+
14
# before_action doesn't seem to exist, so this doesn't make sense.
25
Rails/ActionFilter:
36
Enabled: false

rubocop-airbnb/config/rubocop-rspec.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ RSpec/DescribedClass:
5656
RSpec/EmptyExampleGroup:
5757
Description: Checks if an example group does not include any tests.
5858
Enabled: true
59-
CustomIncludeMethods: []
6059

6160
RSpec/EmptyLineAfterExampleGroup:
6261
Description: Checks if there is an empty line after example group blocks.
@@ -155,10 +154,6 @@ RSpec/InstanceVariable:
155154
Description: 'Checks for the usage of instance variables.'
156155
Enabled: false
157156

158-
RSpec/InvalidPredicateMatcher:
159-
Description: Checks invalid usage for predicate matcher.
160-
Enabled: false
161-
162157
RSpec/ItBehavesLike:
163158
Description: Checks that only one `it_behaves_like` style is used.
164159
Enabled: false
@@ -314,18 +309,18 @@ RSpec/VoidExpect:
314309
Description: This cop checks void `expect()`.
315310
Enabled: false
316311

317-
Capybara/CurrentPathExpectation:
312+
RSpec/Capybara/CurrentPathExpectation:
318313
Description: Checks that no expectations are set on Capybara's `current_path`.
319314
Enabled: false
320315

321-
Capybara/FeatureMethods:
316+
RSpec/Capybara/FeatureMethods:
322317
Description: Checks for consistent method usage in feature specs.
323318
Enabled: false
324319

325-
FactoryBot/AttributeDefinedStatically:
320+
RSpec/FactoryBot/AttributeDefinedStatically:
326321
Description: Always declare attribute values as blocks.
327322
Enabled: false
328323

329-
FactoryBot/CreateList:
324+
RSpec/FactoryBot/CreateList:
330325
Description: Checks for create_list usage.
331326
Enabled: true

rubocop-airbnb/lib/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module Airbnb
5656
# class Bar # nested class
5757
# end
5858
# end
59-
class ClassOrModuleDeclaredInWrongFile < Cop
59+
class ClassOrModuleDeclaredInWrongFile < Base
6060
include Inflections
6161
include RailsAutoloading
6262

rubocop-airbnb/lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Airbnb
2222
# module Foo
2323
# BAZ = 42
2424
# end
25-
class ConstAssignedInWrongFile < Cop
25+
class ConstAssignedInWrongFile < Base
2626
include Inflections
2727
include RailsAutoloading
2828

rubocop-airbnb/lib/rubocop/cop/airbnb/continuation_slash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module RuboCop
22
module Cop
33
module Airbnb
4-
class ContinuationSlash < Cop
4+
class ContinuationSlash < Base
55
MSG = 'Slash continuation should be reserved for closed string continuation. ' \
66
'Many times it is used to get around other existing rules.'.freeze
77

rubocop-airbnb/lib/rubocop/cop/airbnb/default_scope.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Cop
33
module Airbnb
44
# Cop to help prevent the scorge of Default Scopes from ActiveRecord.
55
# Once in place they are almost impossible to remove.
6-
class DefaultScope < Cop
6+
class DefaultScope < Base
77
MSG = 'Avoid `default_scope`. Default scopes make it difficult to '\
88
'refactor data access patterns since the scope becomes part '\
99
'of every query unless explicitly excluded, even when it is '\

rubocop-airbnb/lib/rubocop/cop/airbnb/factory_attr_references_class.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Airbnb
44
# Cop to enforce "attr { CONST }" instead of "attr CONST" in factories,
55
# because the latter forces autoload, which slows down spec startup time and
66
# Zeus reload time after touching a model.
7-
class FactoryAttrReferencesClass < Cop
7+
class FactoryAttrReferencesClass < Base
88
MSG = "Instead of attr_name MyClass::MY_CONST, use attr_name { MyClass::MY_CONST }. " \
99
"This enables faster spec startup time and Zeus reload time.".freeze
1010

0 commit comments

Comments
 (0)