Skip to content

Commit

Permalink
Add new global ActiveSupportExtensionsEnabled option
Browse files Browse the repository at this point in the history
  • Loading branch information
nobuyo committed Jun 17, 2022
1 parent d19f902 commit f57a0e3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
@@ -0,0 +1 @@
* [#10699](https://github.com/rubocop/rubocop/pull/10699): Add new global `ActiveSupportExtensionsEnabled` option. ([@nobuyo][])
2 changes: 2 additions & 0 deletions config/default.yml
Expand Up @@ -153,6 +153,8 @@ AllCops:
rubocop-sequel: [sequel]
rubocop-rake: [rake]
rubocop-graphql: [graphql]
# Enable/Disable checking the methods extended by Active Support.
ActiveSupportExtensionsEnabled: false

#################### Bundler ###############################

Expand Down
11 changes: 11 additions & 0 deletions docs/modules/ROOT/pages/configuration.adoc
Expand Up @@ -784,3 +784,14 @@ The following is an example of specifying `Rails` department.
Rails:
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails
----

== Enable checking Active Support extensions

Some cops for checking specified methods (e.g. `Style/HashExcept`) supports Active Support extensions.
This is off by default, but can be enabled by the `ActiveSupportExtensionsEnabled` option.

[source,yaml]
----
AllCops:
ActiveSupportExtensionsEnabled: true
----
4 changes: 4 additions & 0 deletions lib/rubocop/config.rb
Expand Up @@ -146,6 +146,10 @@ def enabled_new_cops?
for_all_cops['NewCops'] == 'enable'
end

def active_support_extensions_enabled?
for_all_cops['ActiveSupportExtensionsEnabled']
end

def file_to_include?(file)
relative_file_path = path_relative_to_config(file)

Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/base.rb
Expand Up @@ -220,6 +220,10 @@ def target_rails_version
@config.target_rails_version
end

def active_support_extensions_enabled?
@config.active_support_extensions_enabled?
end

def relevant_file?(file)
file == RuboCop::AST::ProcessedSource::STRING_SOURCE_NAME ||
(file_name_matches_any?(file, 'Include', true) &&
Expand Down

0 comments on commit f57a0e3

Please sign in to comment.