Skip to content

Commit

Permalink
Update rubocop + start testing on Ruby 3.0 (#637)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ixti authored Dec 29, 2020
1 parent e615178 commit f4fb336
Show file tree
Hide file tree
Showing 31 changed files with 373 additions and 254 deletions.
36 changes: 9 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ on:
pull_request:
branches: [ master ]

env:
BUNDLE_WITHOUT: "development"
JRUBY_OPTS: "--dev --debug"

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
ruby: [ ruby-2.4, ruby-2.5, ruby-2.6, ruby-2.7, jruby-9.2.11 ]
ruby: [ ruby-2.4, ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0, jruby-9.2 ]
os: [ ubuntu-latest ]

steps:
Expand All @@ -21,22 +25,9 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- uses: actions/cache@v1
with:
path: vendor/bundle
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-

- name: bundle install
run: |
bundle config set path "vendor/bundle"
bundle config set without "development"
bundle install --jobs 4
bundler-cache: true

- name: bundle exec rspec
env:
JRUBY_OPTS: --debug
run: bundle exec rspec --format progress --force-colour

- name: Prepare Coveralls test coverage report
Expand Down Expand Up @@ -66,18 +57,9 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4
bundler-cache: true

- uses: actions/cache@v1
with:
path: vendor/bundle
key: bundle-use-ruby-lint-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: bundle-use-ruby-lint-

- name: bundle install
run: |
bundle config set path "vendor/bundle"
bundle config set without "development"
bundle install --jobs 4
- name: bundle exec rubocop
run: bundle exec rubocop --format progress --color

- run: bundle exec rubocop --color
- run: bundle exec rake verify_measurements
131 changes: 7 additions & 124 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,10 @@
require: rubocop-performance
inherit_from:
- .rubocop_todo.yml
- .rubocop/layout.yml
- .rubocop/style.yml

AllCops:
TargetRubyVersion: 2.3
DefaultFormatter: fuubar
DisplayCopNames: true

## Layout ######################################################################

Layout/AlignHash:
EnforcedColonStyle: table
EnforcedHashRocketStyle: table

Layout/DotPosition:
EnforcedStyle: trailing

Layout/SpaceAroundOperators:
AllowForAlignment: true

Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

## Metrics #####################################################################

Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Exclude:
- "spec/**/*"
- "**/*.gemspec"

Metrics/BlockNesting:
Max: 2

Metrics/ClassLength:
CountComments: false
Max: 125

# TODO: Lower to 6
Metrics/CyclomaticComplexity:
Max: 8

Metrics/PerceivedComplexity:
Max: 8

# TODO: Lower to 80
Metrics/LineLength:
AllowURI: true
Max: 143

# TODO: Lower to 15
Metrics/MethodLength:
CountComments: false
Max: 25

Metrics/ModuleLength:
CountComments: false
Max: 120

Metrics/ParameterLists:
Max: 5
CountKeywordArgs: true

## Performance #################################################################

# XXX: requires ruby 2.4+
Performance/RegexpMatch:
Enabled: false

Performance/UnfreezeString:
Enabled: false

## Style #######################################################################

Style/CollectionMethods:
PreferredMethods:
collect: 'map'
reduce: 'inject'
find: 'detect'
find_all: 'select'

Style/Documentation:
Enabled: false

Style/DoubleNegation:
Enabled: false

Style/EachWithObject:
Enabled: false

Style/Encoding:
Enabled: false

Style/EmptyCaseCondition:
Enabled: false

# XXX: Lots of times it suggests making code terrible to read.
Style/GuardClause:
Enabled: false

Style/HashSyntax:
EnforcedStyle: hash_rockets

Style/Lambda:
Enabled: false

Style/OptionHash:
Enabled: true

# XXX: requires ruby 2.3+
Style/SafeNavigation:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/TrivialAccessors:
Enabled: false

Style/YodaCondition:
Enabled: false

Style/FormatStringToken:
EnforcedStyle: unannotated

Style/RescueStandardError:
EnforcedStyle: implicit
NewCops: enable
TargetRubyVersion: 2.4
8 changes: 8 additions & 0 deletions .rubocop/layout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Layout/DotPosition:
Enabled: true
EnforcedStyle: leading

Layout/HashAlignment:
Enabled: true
EnforcedColonStyle: table
EnforcedHashRocketStyle: table
32 changes: 32 additions & 0 deletions .rubocop/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Style/Documentation:
Enabled: false

Style/DocumentDynamicEvalDefinition:
Enabled: true
Exclude:
- 'spec/**/*.rb'

Style/FormatStringToken:
Enabled: true
EnforcedStyle: unannotated

Style/HashSyntax:
Enabled: true
EnforcedStyle: hash_rockets

Style/OptionHash:
Enabled: true

Style/RescueStandardError:
Enabled: true
EnforcedStyle: implicit

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

Style/WordArray:
Enabled: true

Style/YodaCondition:
Enabled: false
Loading

0 comments on commit f4fb336

Please sign in to comment.