Skip to content

Commit f4fb336

Browse files
authored
Update rubocop + start testing on Ruby 3.0 (#637)
* Cleanup GitHub Actions CI config * Update rubocop Split config into sections and generate new _todo file with excludes. * Add Ruby 3.0 support - Add ruby-3.0 to CI test matrix - Fix testsuite to support Ruby 3.0
1 parent e615178 commit f4fb336

31 files changed

+373
-254
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ on:
66
pull_request:
77
branches: [ master ]
88

9+
env:
10+
BUNDLE_WITHOUT: "development"
11+
JRUBY_OPTS: "--dev --debug"
12+
913
jobs:
1014
test:
1115
runs-on: ${{ matrix.os }}
1216

1317
strategy:
1418
matrix:
15-
ruby: [ ruby-2.4, ruby-2.5, ruby-2.6, ruby-2.7, jruby-9.2.11 ]
19+
ruby: [ ruby-2.4, ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0, jruby-9.2 ]
1620
os: [ ubuntu-latest ]
1721

1822
steps:
@@ -21,22 +25,9 @@ jobs:
2125
- uses: ruby/setup-ruby@v1
2226
with:
2327
ruby-version: ${{ matrix.ruby }}
24-
25-
- uses: actions/cache@v1
26-
with:
27-
path: vendor/bundle
28-
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
29-
restore-keys: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
30-
31-
- name: bundle install
32-
run: |
33-
bundle config set path "vendor/bundle"
34-
bundle config set without "development"
35-
bundle install --jobs 4
28+
bundler-cache: true
3629

3730
- name: bundle exec rspec
38-
env:
39-
JRUBY_OPTS: --debug
4031
run: bundle exec rspec --format progress --force-colour
4132

4233
- name: Prepare Coveralls test coverage report
@@ -66,18 +57,9 @@ jobs:
6657
- uses: ruby/setup-ruby@v1
6758
with:
6859
ruby-version: 2.4
60+
bundler-cache: true
6961

70-
- uses: actions/cache@v1
71-
with:
72-
path: vendor/bundle
73-
key: bundle-use-ruby-lint-${{ hashFiles('**/Gemfile.lock') }}
74-
restore-keys: bundle-use-ruby-lint-
75-
76-
- name: bundle install
77-
run: |
78-
bundle config set path "vendor/bundle"
79-
bundle config set without "development"
80-
bundle install --jobs 4
62+
- name: bundle exec rubocop
63+
run: bundle exec rubocop --format progress --color
8164

82-
- run: bundle exec rubocop --color
8365
- run: bundle exec rake verify_measurements

.rubocop.yml

Lines changed: 7 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,10 @@
1-
require: rubocop-performance
1+
inherit_from:
2+
- .rubocop_todo.yml
3+
- .rubocop/layout.yml
4+
- .rubocop/style.yml
25

36
AllCops:
4-
TargetRubyVersion: 2.3
7+
DefaultFormatter: fuubar
58
DisplayCopNames: true
6-
7-
## Layout ######################################################################
8-
9-
Layout/AlignHash:
10-
EnforcedColonStyle: table
11-
EnforcedHashRocketStyle: table
12-
13-
Layout/DotPosition:
14-
EnforcedStyle: trailing
15-
16-
Layout/SpaceAroundOperators:
17-
AllowForAlignment: true
18-
19-
Layout/SpaceInsideHashLiteralBraces:
20-
EnforcedStyle: no_space
21-
22-
## Metrics #####################################################################
23-
24-
Metrics/AbcSize:
25-
Enabled: false
26-
27-
Metrics/BlockLength:
28-
Exclude:
29-
- "spec/**/*"
30-
- "**/*.gemspec"
31-
32-
Metrics/BlockNesting:
33-
Max: 2
34-
35-
Metrics/ClassLength:
36-
CountComments: false
37-
Max: 125
38-
39-
# TODO: Lower to 6
40-
Metrics/CyclomaticComplexity:
41-
Max: 8
42-
43-
Metrics/PerceivedComplexity:
44-
Max: 8
45-
46-
# TODO: Lower to 80
47-
Metrics/LineLength:
48-
AllowURI: true
49-
Max: 143
50-
51-
# TODO: Lower to 15
52-
Metrics/MethodLength:
53-
CountComments: false
54-
Max: 25
55-
56-
Metrics/ModuleLength:
57-
CountComments: false
58-
Max: 120
59-
60-
Metrics/ParameterLists:
61-
Max: 5
62-
CountKeywordArgs: true
63-
64-
## Performance #################################################################
65-
66-
# XXX: requires ruby 2.4+
67-
Performance/RegexpMatch:
68-
Enabled: false
69-
70-
Performance/UnfreezeString:
71-
Enabled: false
72-
73-
## Style #######################################################################
74-
75-
Style/CollectionMethods:
76-
PreferredMethods:
77-
collect: 'map'
78-
reduce: 'inject'
79-
find: 'detect'
80-
find_all: 'select'
81-
82-
Style/Documentation:
83-
Enabled: false
84-
85-
Style/DoubleNegation:
86-
Enabled: false
87-
88-
Style/EachWithObject:
89-
Enabled: false
90-
91-
Style/Encoding:
92-
Enabled: false
93-
94-
Style/EmptyCaseCondition:
95-
Enabled: false
96-
97-
# XXX: Lots of times it suggests making code terrible to read.
98-
Style/GuardClause:
99-
Enabled: false
100-
101-
Style/HashSyntax:
102-
EnforcedStyle: hash_rockets
103-
104-
Style/Lambda:
105-
Enabled: false
106-
107-
Style/OptionHash:
108-
Enabled: true
109-
110-
# XXX: requires ruby 2.3+
111-
Style/SafeNavigation:
112-
Enabled: false
113-
114-
Style/StringLiterals:
115-
EnforcedStyle: double_quotes
116-
117-
Style/TrivialAccessors:
118-
Enabled: false
119-
120-
Style/YodaCondition:
121-
Enabled: false
122-
123-
Style/FormatStringToken:
124-
EnforcedStyle: unannotated
125-
126-
Style/RescueStandardError:
127-
EnforcedStyle: implicit
9+
NewCops: enable
10+
TargetRubyVersion: 2.4

.rubocop/layout.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Layout/DotPosition:
2+
Enabled: true
3+
EnforcedStyle: leading
4+
5+
Layout/HashAlignment:
6+
Enabled: true
7+
EnforcedColonStyle: table
8+
EnforcedHashRocketStyle: table

.rubocop/style.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Style/Documentation:
2+
Enabled: false
3+
4+
Style/DocumentDynamicEvalDefinition:
5+
Enabled: true
6+
Exclude:
7+
- 'spec/**/*.rb'
8+
9+
Style/FormatStringToken:
10+
Enabled: true
11+
EnforcedStyle: unannotated
12+
13+
Style/HashSyntax:
14+
Enabled: true
15+
EnforcedStyle: hash_rockets
16+
17+
Style/OptionHash:
18+
Enabled: true
19+
20+
Style/RescueStandardError:
21+
Enabled: true
22+
EnforcedStyle: implicit
23+
24+
Style/StringLiterals:
25+
Enabled: true
26+
EnforcedStyle: double_quotes
27+
28+
Style/WordArray:
29+
Enabled: true
30+
31+
Style/YodaCondition:
32+
Enabled: false

0 commit comments

Comments
 (0)