Skip to content

Commit

Permalink
Merge pull request #24 from RadiusNetworks/rubocop-update
Browse files Browse the repository at this point in the history
Update to Rubocop 0.73.0 and Rubocop-Rails 2.2.1
  • Loading branch information
cupakromer authored Jul 23, 2021
2 parents 62833fd + 7d7e24d commit d20b8b9
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_mode:
- Exclude
- IgnoredPatterns

inherit_from: common_rubocop.yml
inherit_from: common_rubocop_rails.yml

# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ before_script:
- "bin/ci-code-review"
script: bin/ci
rvm:
- 2.7
- 2.6
- 2.5
- ruby-head
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@

### Enhancements

- TODO
- Upgrade to Rubocop 0.73.x (Aaron Hill, Aaron Kromer, Ben Reynold, Chris
Hoffman, James Nebeker #24)
- Upgrade to Rubocop Rails 2.2.x (Aaron Hill, Aaron Kromer, Ben Reynold, Chris
Hoffman, James Nebeker #24)
- Adjust common Rubocop configuration (Aaron Hill, Aaron Kromer, Ben Reynold,
Chris Hoffman, James Nebeker #24)
- Target Ruby 2.7 by default
- Enable `Lint/HeredocMethodCallPosition` by default
- Use `StandardError` for the suggested parent classes of errors
- Bump metric check maximums to provide a little more wiggle room
- Disable `Naming/RescuedExceptionsVariableName` by default
- Adjust common Rubocop Rails configuration (Aaron Hill, Aaron Kromer, Ben
Reynold, Chris Hoffman, James Nebeker #24)
- Disable `Rails/IgnoredSkipActionFilterOption` by default

### Bug Fixes

Expand Down
61 changes: 57 additions & 4 deletions common_rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.5.0
TargetRubyVersion: 2.7.0
Exclude:
# Exclude generated binstubs
- 'bin/bundle'
Expand Down Expand Up @@ -79,7 +79,10 @@ Layout/BlockAlignment:
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver,
# special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstParameterIndentation:
#
# TODO: At some point this is split into both Layout/FirstArgumentIndentation
# and Layout/FirstParameterIndentation
Layout/IndentFirstArgument:
Enabled: false

# This project only uses newer Ruby versions which all support the "squiggly"
Expand Down Expand Up @@ -124,6 +127,31 @@ Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*_spec.rb'

# We prefer to enforce a consistent usage for readability
#
# <<~SQL.strip
# bar
# SQL
#
# display(<<~SQL.strip)
# bar
# SQL
#
# Alternatively, refactoring the heredoc into a local also improves
# readability:
#
# custom_sql = <<~SQL
# bar
# SQL
# display(custom_sql.strip)
Lint/HeredocMethodCallPosition:
Enabled: true

# We prefer people suggesting people subclass `StandardError` for their custom
# exceptions as this is a relatively common Ruby idiom.
Lint/InheritException:
EnforcedStyle: standard_error

# Often with benchmarking we don't explicitly "use" a variable or return value.
# We simply need to perform the operation which generates said value for the
# benchmark.
Expand All @@ -133,6 +161,15 @@ Lint/Void:
Exclude:
- 'benchmarks/**/*'

Metrics/AbcSize:
# TODO: When we are able to upgrade to Rubocop 1.5.0 we want to enable the
# following `CountRepeatedAttributes` option. We often find the
# multi-references to the same object to be necessary for reability and that
# for our team it does not increase complexity.
#
# CountRepeatedAttributes: false
Max: 17

# Configuration parameters: CountComments, ExcludedMethods, Max.
# ExcludedMethods: refine
Metrics/BlockLength:
Expand All @@ -146,7 +183,6 @@ Metrics/BlockLength:
- 'chdir'
- 'refine'
- 'Capybara.register_driver'
- 'Gem::Specification.new'
- 'RSpec.configure'
- 'VCR.configure'

Expand Down Expand Up @@ -185,6 +221,12 @@ Metrics/LineLength:
Exclude:
- '**/*.gemspec'

# TODO: Remove this when we get to 0.89.0 as the new default max is 8
#
# Configuration parameters: IgnoredMethods, Max
Metrics/PerceivedComplexity:
Max: 8

# This is overly pedantic (only allowing `other` as the parameter name). Ruby
# core doesn't follow this consistently either. Looking at several classes
# throughout Ruby core we do often see `other`, but also often `obj` or
Expand Down Expand Up @@ -235,6 +277,13 @@ Naming/MemoizedInstanceVariableName:
acceptable.
EnforcedStyleForLeadingUnderscores: optional

# We don't really care about this check. Sometimes using something simple such
# as `err` is just fine. Other times it may improve readability to have a more
# descriptive name. We feel this is a personal judgement call and not something
# that needs to be enforced.
Naming/RescuedExceptionsVariableName:
Enabled: false

# `alias` behavior changes on scope. In general we expect the behavior to be
# that which is defined by `alias_method`.
#
Expand Down Expand Up @@ -284,7 +333,10 @@ Style/AsciiComments:
# - Prefer `{...}` over `do...end` for functional blocks.
#
# When the return value of the method receiving the block is important prefer
# `{..}` over `do..end`.
# `{...}` over `do...end`.
#
# Some people enjoy the compact readability of `{...}` for one-liners so we
# allow that style as well.
#
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining
Expand All @@ -297,6 +349,7 @@ Style/BlockDelimiters:
When the return value of the method receiving the block is important prefer
`{..}` over `do..end`.
AllowBracesOnProceduralOneLiners: true
Enabled: true
EnforcedStyle: semantic
ProceduralMethods:
Expand Down
13 changes: 9 additions & 4 deletions common_rubocop_rails.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
require: rubocop-rails

inherit_mode:
merge:
- Exclude
- IgnoredPatterns

inherit_from: common_rubocop.yml

# Enable additional Rails cops
Rails:
Enabled: true

AllCops:
Exclude:
- 'bin/puma'
Expand Down Expand Up @@ -145,6 +143,13 @@ Rails/FindEach:
Rails/HasAndBelongsToMany:
Enabled: false

# We find the combo `:only` and `:if` readable. While the `:except` and `:if`
# combo is easier to read as a combined proc. As a team we are fine with
# handling this in PR reviews, until such time which Rubocop provides an option
# for us to configure this.
Rails/IgnoredSkipActionFilterOption:
Enabled: false

# The ActiveSupport monkey patches for `present?` are nearly all defined as:
#
# !blank?
Expand Down
7 changes: 4 additions & 3 deletions radius-spec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 2.5"

spec.add_runtime_dependency "rspec", "~> 3.7"
spec.add_runtime_dependency "rubocop", "~> 0.62.0"
spec.add_runtime_dependency "rubocop", "~> 0.73.0"
spec.add_runtime_dependency "rubocop-rails", "~> 2.2.1"

spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "bundler", ">= 2.2.10"
spec.add_development_dependency "rake", ">= 12.0", "< 14.0"
end

0 comments on commit d20b8b9

Please sign in to comment.