Skip to content

Commit

Permalink
Remove base rubocop rules redefined/extended by rubocop-rails (clears…
Browse files Browse the repository at this point in the history
… warning)

See #25 (comment)

Fixes #25
  • Loading branch information
searls committed Jan 8, 2024
1 parent 9d20ad6 commit acccb02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
12 changes: 0 additions & 12 deletions config/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ AllCops:
# as the default.
TargetRailsVersion: ~

# This cop from rubocop was added to the Rubocop-Rails
# config as part of this PR:
# https://github.com/rubocop/rubocop-rails/pull/1014
# in order to support some Rails-specific methods. At the
# time of writing, it's disabled in Standard, so it's
# disabled here.
Lint/RedundantSafeNavigation:
Enabled: false

Lint/SafeNavigationChain:
Enabled: true
AllowedMethods:
Expand Down Expand Up @@ -427,6 +418,3 @@ Rails/WhereNot:

Rails/WhereNotWithMultipleConditions:
Enabled: false

Style/InvertibleUnlessCondition:
Enabled: false
16 changes: 15 additions & 1 deletion lib/standard/rails/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def rules(context)
LintRoller::Rules.new(
type: :object,
config_format: :rubocop,
value: rules_with_config_applied
value: without_extended_rule_configs(
rules_with_config_applied
)
)
end

Expand All @@ -44,6 +46,18 @@ def rules_with_config_applied
)
end

# rubocop-rails adds additional options to a couple out-of-the-box cops
# but Standard (1) doesn't enable these to begin with and (2) doesn't
# allow rules' configs to be edited once they are defined, so we'll just
# remove them here
#
# See: https://github.com/standardrb/standard-rails/issues/25#issuecomment-1881127173
def without_extended_rule_configs(rules)
rules.reject { |(name,_)|
["Style/InvertibleUnlessCondition", "Lint/SafeNavigationChain"].include?(name)
}.to_h
end

# This is not fantastic.
#
# When you `require "rubocop-rails"`, it will not only load the cops,
Expand Down

0 comments on commit acccb02

Please sign in to comment.