Skip to content

AllCops does not support TargetRailsVersion parameter warning #141

@andy-rootly

Description

@andy-rootly

This issue was written with Claude Code's assistance.

Problem

When using rubocop 1.84.2 / rubocop-rails 2.34.3, running RuboCop produces:

Warning: AllCops does not support TargetRailsVersion parameter.

Cause

rubocop-rails handles this in its own plugin.rb by monkey-patching ConfigValidator::COMMON_PARAMS to include TargetRailsVersion:

# FIXME: This is a dirty hack relying on a private constant to prevent
# "Warning: AllCops does not support TargetRailsVersion parameter".
ConfigValidator.const_set(:COMMON_PARAMS, ConfigValidator::COMMON_PARAMS.dup << 'TargetRailsVersion')

But standard-rails bypasses rubocop-rails' normal plugin loading (via load_rubocop_rails_without_the_monkey_patch.rb), so that hack never runs.

PR #97 (released in v1.6.0) addressed this for MigratedSchemaVersion (unconditional delete) but only removes TargetRailsVersion when its value is nil:

all_cops.delete("MigratedSchemaVersion")
all_cops.delete("TargetRailsVersion") if all_cops.key?("TargetRailsVersion") && all_cops["TargetRailsVersion"].nil?

Since rubocop-rails' default.yml sets TargetRailsVersion: ~ (YAML nil), the conditional delete does match — but only before a user sets a target_rails_version in .standard.yml. In practice, the warning still appears (possibly due to config merging order or rubocop version differences).

Gem versions

rubocop (1.84.2)
rubocop-rails (2.34.3)
standard (1.54.0)
standard-rails (1.6.0)

Suggested fix

Unconditionally remove TargetRailsVersion from AllCops, matching the existing MigratedSchemaVersion handling:

all_cops.delete("MigratedSchemaVersion")
all_cops.delete("TargetRailsVersion")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions