Skip to content

Commit 063bf20

Browse files
authored
Merge pull request #1445 from koic/fix_an_error_when_using_target_rails_version
[Fix #1442] Fix an incorrect behavior when using `AllCops: TargetRailsVersion`
2 parents d8bb510 + da9d36f commit 063bf20

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1442](https://github.com/rubocop/rubocop-rails/issues/1442): Fix an incorrect behavior when using `AllCops: TargetRailsVersion`. ([@koic][])

lib/rubocop/rails/plugin.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,25 @@ def rules(_context)
2424

2525
ConfigObsoletion.files << project_root.join('config', 'obsoletion.yml')
2626

27+
# FIXME: This is a dirty hack relying on a private constant to prevent
28+
# "Warning: AllCops does not support TargetRailsVersion parameter".
29+
# It should be updated to a better design in the future.
30+
without_warnings do
31+
ConfigValidator.const_set(:COMMON_PARAMS, ConfigValidator::COMMON_PARAMS.dup << 'TargetRailsVersion')
32+
end
33+
2734
LintRoller::Rules.new(type: :path, config_format: :rubocop, value: project_root.join('config', 'default.yml'))
2835
end
36+
37+
private
38+
39+
def without_warnings
40+
original_verbose = $VERBOSE
41+
$VERBOSE = nil
42+
yield
43+
ensure
44+
$VERBOSE = original_verbose
45+
end
2946
end
3047
end
3148
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy