Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# of RuboCop built-in cops in this file, we need to monitor it for changes
# in rubocop-rails and keep it up to date.
#
# Last updated from rubocop-rails v2.31.0
# Last updated from rubocop-rails v2.32.0

# frozen_string_literal: true

Expand Down
13 changes: 12 additions & 1 deletion lib/standard/rails/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def supported?(context)
def rules(context)
trick_rubocop_into_thinking_we_required_rubocop_rails!

# Workaround to avoid "Warning: AllCops does not support..." output
without_warnings do
RuboCop::ConfigValidator.const_set :COMMON_PARAMS, updated_common_params
end

LintRoller::Rules.new(
type: :object,
config_format: :rubocop,
Expand All @@ -35,6 +40,12 @@ def rules(context)

private

def updated_common_params
RuboCop::ConfigValidator::COMMON_PARAMS.dup.tap do |common|
%w[MigratedSchemaVersion TargetRailsVersion].each { |param| common << param }
end
end

def rules_with_config_applied
@merges_upstream_metadata.merge(
YAML.load_file(Pathname.new(__dir__).join("../../../config/base.yml")).tap do |rules|
Expand All @@ -54,7 +65,7 @@ def rules_with_config_applied
# 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)
["Style/InvertibleUnlessCondition", "Lint/SafeNavigationChain", "Lint/UselessAccessModifier"].include?(name)
}.to_h
end

Expand Down
11 changes: 11 additions & 0 deletions test/standard/rails/plugin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ def test_configuring_target_rails_version

assert_equal 5.2, result.value["AllCops"]["TargetRailsVersion"]
end

def test_no_parameter_warnings_when_validating_config
subject = Plugin.new({})
rules = subject.rules(LintRoller::Context.new)

_out, err = capture_io do
RuboCop::Config.create(rules.value, "inline.yml", check: true)
end

assert_equal "", err
end
end
end