diff --git a/CHANGELOG.md b/CHANGELOG.md index a1e0b47b789..6ab93318b25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changes * [#7077](https://github.com/rubocop-hq/rubocop/issues/7077): **(Breaking)** Further standardisation of cop names. ([@scottmatthewman][]) +* [#7469](https://github.com/rubocop-hq/rubocop/pull/7469): Change a terminology from `Whitelist` and `Blacklist` to `Allowlist` and `Denylist`. ([@koic][]) ## 0.76.0 (2019-10-28) diff --git a/config/default.yml b/config/default.yml index fc93465ff32..df5f9ad85d2 100644 --- a/config/default.yml +++ b/config/default.yml @@ -141,11 +141,12 @@ Bundler/GemComment: Description: 'Add a comment describing each gem.' Enabled: false VersionAdded: '0.59' + VersionChanged: '0.77' Include: - '**/*.gemfile' - '**/Gemfile' - '**/gems.rb' - Whitelist: [] + IgnoredGems: [] Bundler/InsecureProtocolSource: Description: >- @@ -1590,8 +1591,8 @@ Lint/SafeNavigationChain: Description: 'Do not chain ordinary method call after safe navigation operator.' Enabled: true VersionAdded: '0.47' - VersionChanged: '0.56' - Whitelist: + VersionChanged: '0.77' + AllowedMethods: - present? - blank? - presence @@ -1605,14 +1606,14 @@ Lint/SafeNavigationConsistency: for all method calls on that same object. Enabled: true VersionAdded: '0.55' - Whitelist: + VersionChanged: '0.77' + AllowedMethods: - present? - blank? - presence - try - try! - Lint/SafeNavigationWithEmpty: Description: 'Avoid `foo&.empty?` in conditionals.' Enabled: true @@ -1902,9 +1903,9 @@ Naming/BlockParameterName: # Parameter names may be equal to or greater than this value MinNameLength: 1 AllowNamesEndingInNumbers: true - # Whitelisted names that will not register an offense + # Allowed names that will not register an offense AllowedNames: [] - # Blacklisted names that will register an offense + # Forbidden names that will register an offense ForbiddenNames: [] Naming/ClassAndModuleCamelCase: @@ -1998,7 +1999,7 @@ Naming/HeredocDelimiterNaming: StyleGuide: '#heredoc-delimiters' Enabled: true VersionAdded: '0.50' - Blacklist: + ForbiddenDelimiters: - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/' Naming/MemoizedInstanceVariableName: @@ -2040,7 +2041,7 @@ Naming/MethodParameterName: # Parameter names may be equal to or greater than this value MinNameLength: 3 AllowNamesEndingInNumbers: true - # Whitelisted names that will not register an offense + # Allowed names that will not register an offense AllowedNames: - io - id @@ -2052,7 +2053,7 @@ Naming/MethodParameterName: - ip - db - os - # Blacklisted names that will register an offense + # Fobidden names that will register an offense ForbiddenNames: [] Naming/PredicateName: @@ -2060,20 +2061,20 @@ Naming/PredicateName: StyleGuide: '#bool-methods-qmark' Enabled: true VersionAdded: '0.50' - VersionChanged: '0.51' + VersionChanged: '0.77' # Predicate name prefixes. NamePrefix: - is_ - has_ - have_ # Predicate name prefixes that should be removed. - NamePrefixBlacklist: + ForbiddenPrefixes: - is_ - has_ - have_ - # Predicate names which, despite having a blacklisted prefix, or no `?`, + # Predicate names which, despite having a forbidden prefix, or no `?`, # should still be accepted - NameWhitelist: + AllowedMethods: - is_a? # Method definition macros for dynamically generated methods. MethodDefinitionMacros: @@ -2885,8 +2886,9 @@ Style/IpAddresses: Description: "Don't include literal IP addresses in code." Enabled: false VersionAdded: '0.58' - # Allow strings to be whitelisted - Whitelist: + VersionChanged: '0.77' + # Allow addresses to be permitted + AllowedAddresses: - "::" # :: is a valid IPv6 address, but could potentially be legitimately in code @@ -3159,8 +3161,8 @@ Style/NestedParenthesizedCalls: argument list of another parenthesized method call. Enabled: true VersionAdded: '0.36' - VersionChanged: '0.50' - Whitelist: + VersionChanged: '0.77' + AllowedMethods: - be - be_a - be_an @@ -3537,11 +3539,11 @@ Style/SafeNavigation: safe navigation (`&.`). Enabled: true VersionAdded: '0.43' - VersionChanged: '0.56' + VersionChanged: '0.77' # Safe navigation may cause a statement to start returning `nil` in addition # to whatever it used to return. ConvertCodeThatCanStartToReturnNil: false - Whitelist: + AllowedMethods: - present? - blank? - presence @@ -3819,7 +3821,7 @@ Style/TrivialAccessors: StyleGuide: '#attr_family' Enabled: true VersionAdded: '0.9' - VersionChanged: '0.38' + VersionChanged: '0.77' # When set to `false` the cop will suggest the use of accessor methods # in situations like: # @@ -3840,7 +3842,7 @@ Style/TrivialAccessors: # Commonly used in DSLs AllowDSLWriters: false IgnoreClassMethods: false - Whitelist: + AllowedMethod: - to_ary - to_a - to_c diff --git a/lib/rubocop/config_obsoletion.rb b/lib/rubocop/config_obsoletion.rb index dc490a3b651..247bc32e006 100644 --- a/lib/rubocop/config_obsoletion.rb +++ b/lib/rubocop/config_obsoletion.rb @@ -158,6 +158,42 @@ class ConfigObsoletion parameters: 'SafeMode', alternative: '`SafeMode` has been removed. ' \ 'Use `SafeAutoCorrect` instead.' + }, + { + cops: 'Bundler/GemComment', + parameters: 'Whitelist', + alternative: '`Whitelist` has been renamed to `IgnoredGems`.' + }, + { + cops: %w[ + Lint/SafeNavigationChain Lint/SafeNavigationConsistency + Style/NestedParenthesizedCalls Style/SafeNavigation + Style/TrivialAccessors + ], + parameters: 'Whitelist', + alternative: '`Whitelist` has been renamed to `AllowedMethods`.' + }, + { + cops: 'Style/IpAddresses', + parameters: 'Whitelist', + alternative: '`Whitelist` has been renamed to `AllowedAddresses`.' + }, + { + cops: 'Naming/HeredocDelimiterNaming', + parameters: 'Blacklist', + alternative: '`Blacklist` has been renamed to `ForbiddenDelimiters`.' + }, + { + cops: 'Naming/PredicateName', + parameters: 'NamePrefixBlacklist', + alternative: '`NamePrefixBlacklist` has been renamed to ' \ + '`ForbiddenPrefixes`.' + }, + { + cops: 'Naming/PredicateName', + parameters: 'NameWhitelist', + alternative: '`NameWhitelist` has been renamed to ' \ + '`AllowedMethods`.' } ].freeze diff --git a/lib/rubocop/cop/bundler/gem_comment.rb b/lib/rubocop/cop/bundler/gem_comment.rb index 09b5ef18c90..aa01f0b0315 100644 --- a/lib/rubocop/cop/bundler/gem_comment.rb +++ b/lib/rubocop/cop/bundler/gem_comment.rb @@ -24,7 +24,7 @@ class GemComment < Cop def on_send(node) return unless gem_declaration?(node) - return if whitelisted_gem?(node) + return if ignored_gem?(node) return if commented?(node) add_offense(node) @@ -54,9 +54,9 @@ def preceding_comment?(node1, node2) comment_line?(node2.loc.expression.source) end - def whitelisted_gem?(node) - whitelist = Array(cop_config['Whitelist']) - whitelist.include?(node.first_argument.value) + def ignored_gem?(node) + ignored_gems = Array(cop_config['IgnoredGems']) + ignored_gems.include?(node.first_argument.value) end end end diff --git a/lib/rubocop/cop/mixin/nil_methods.rb b/lib/rubocop/cop/mixin/nil_methods.rb index 8c26e778dea..220d47a850c 100644 --- a/lib/rubocop/cop/mixin/nil_methods.rb +++ b/lib/rubocop/cop/mixin/nil_methods.rb @@ -5,20 +5,20 @@ module Cop # This module provides a list of methods that are: # 1. In the NilClass by default # 2. Added to NilClass by explicitly requiring any standard libraries - # 3. Cop's configuration parameter Whitelist. + # 3. Cop's configuration parameter AllowedMethods. module NilMethods private def nil_methods - nil.methods + other_stdlib_methods + whitelist + nil.methods + other_stdlib_methods + allowed_methods end def other_stdlib_methods [:to_d] end - def whitelist - cop_config['Whitelist'].map(&:to_sym) + def allowed_methods + cop_config['AllowedMethods'].map(&:to_sym) end end end diff --git a/lib/rubocop/cop/naming/block_parameter_name.rb b/lib/rubocop/cop/naming/block_parameter_name.rb index 30fce45c4ea..7f4a3d544ce 100644 --- a/lib/rubocop/cop/naming/block_parameter_name.rb +++ b/lib/rubocop/cop/naming/block_parameter_name.rb @@ -11,9 +11,9 @@ module Naming # The `AllowNamesEndingInNumbers` config option takes a boolean. When # set to false, this cop will register offenses for names ending with # numbers. Its default is false. The `AllowedNames` config option - # takes an array of whitelisted names that will never register an + # takes an array of permitted names that will never register an # offense. The `ForbiddenNames` config option takes an array of - # blacklisted names that will always register an offense. + # restricted names that will always register an offense. # # @example # # bad diff --git a/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb b/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb index 6b3fe9d9275..d3ea71e4147 100644 --- a/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +++ b/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb @@ -5,7 +5,7 @@ module Cop module Naming # This cop checks that your heredocs are using meaningful delimiters. # By default it disallows `END` and `EO*`, and can be configured through - # blacklisting additional delimiters. + # forbidden listing additional delimiters. # # @example # @@ -41,13 +41,13 @@ def meaningful_delimiters?(node) return false unless delimiters =~ /\w/ - blacklisted_delimiters.none? do |blacklisted_delimiter| - delimiters =~ Regexp.new(blacklisted_delimiter) + forbidden_delimiters.none? do |forbidden_delimiter| + delimiters =~ Regexp.new(forbidden_delimiter) end end - def blacklisted_delimiters - cop_config['Blacklist'] || [] + def forbidden_delimiters + cop_config['ForbiddenDelimiters'] || [] end end end diff --git a/lib/rubocop/cop/naming/method_parameter_name.rb b/lib/rubocop/cop/naming/method_parameter_name.rb index 7981332aa6b..e96269a2b36 100644 --- a/lib/rubocop/cop/naming/method_parameter_name.rb +++ b/lib/rubocop/cop/naming/method_parameter_name.rb @@ -11,9 +11,9 @@ module Naming # The `AllowNamesEndingInNumbers` config option takes a boolean. When # set to false, this cop will register offenses for names ending with # numbers. Its default is false. The `AllowedNames` config option - # takes an array of whitelisted names that will never register an + # takes an array of permitted names that will never register an # offense. The `ForbiddenNames` config option takes an array of - # blacklisted names that will always register an offense. + # restricted names that will always register an offense. # # @example # # bad diff --git a/lib/rubocop/cop/naming/predicate_name.rb b/lib/rubocop/cop/naming/predicate_name.rb index 5e8f96cddec..a5a17e1db66 100644 --- a/lib/rubocop/cop/naming/predicate_name.rb +++ b/lib/rubocop/cop/naming/predicate_name.rb @@ -70,11 +70,11 @@ def allowed_method_name?(method_name, prefix) !method_name.match(/^#{prefix}[^0-9]/) || method_name == expected_name(method_name, prefix) || method_name.end_with?('=') || - predicate_whitelist.include?(method_name) + allowed_methods.include?(method_name) end def expected_name(method_name, prefix) - new_name = if prefix_blacklist.include?(prefix) + new_name = if forbidden_prefixes.include?(prefix) method_name.sub(prefix, '') else method_name.dup @@ -87,16 +87,16 @@ def message(method_name, new_name) "Rename `#{method_name}` to `#{new_name}`." end - def prefix_blacklist - cop_config['NamePrefixBlacklist'] + def forbidden_prefixes + cop_config['ForbiddenPrefixes'] end def predicate_prefixes cop_config['NamePrefix'] end - def predicate_whitelist - cop_config['NameWhitelist'] + def allowed_methods + cop_config['AllowedMethods'] end def method_definition_macros(macro_name) diff --git a/lib/rubocop/cop/style/ip_addresses.rb b/lib/rubocop/cop/style/ip_addresses.rb index 83fb257282a..2f366397ec0 100644 --- a/lib/rubocop/cop/style/ip_addresses.rb +++ b/lib/rubocop/cop/style/ip_addresses.rb @@ -28,7 +28,7 @@ def offense?(node) contents = node.source[1...-1] return false if contents.empty? - return false if whitelist.include?(contents.downcase) + return false if allowed_addresses.include?(contents.downcase) # To try to avoid doing two regex checks on every string, # shortcut out if the string does not look like an IP address @@ -47,9 +47,9 @@ def correct_style_detected; end private - def whitelist - whitelist = cop_config['Whitelist'] - Array(whitelist).map(&:downcase) + def allowed_addresses + allowed_addresses = cop_config['AllowedAddresses'] + Array(allowed_addresses).map(&:downcase) end def could_be_ip?(str) diff --git a/lib/rubocop/cop/style/nested_parenthesized_calls.rb b/lib/rubocop/cop/style/nested_parenthesized_calls.rb index eefc9e719a4..e4392f59f03 100644 --- a/lib/rubocop/cop/style/nested_parenthesized_calls.rb +++ b/lib/rubocop/cop/style/nested_parenthesized_calls.rb @@ -49,17 +49,17 @@ def autocorrect(nested) def allowed_omission?(send_node) !send_node.arguments? || send_node.parenthesized? || send_node.setter_method? || send_node.operator_method? || - whitelisted?(send_node) + allowed?(send_node) end - def whitelisted?(send_node) + def allowed?(send_node) send_node.parent.arguments.one? && - whitelisted_methods.include?(send_node.method_name.to_s) && + allowed_methods.include?(send_node.method_name.to_s) && send_node.arguments.one? end - def whitelisted_methods - cop_config['Whitelist'] || [] + def allowed_methods + cop_config['AllowedMethods'] || [] end end end diff --git a/lib/rubocop/cop/style/option_hash.rb b/lib/rubocop/cop/style/option_hash.rb index 987e7d2729f..6bda3898e4c 100644 --- a/lib/rubocop/cop/style/option_hash.rb +++ b/lib/rubocop/cop/style/option_hash.rb @@ -28,7 +28,7 @@ class OptionHash < Cop def on_args(node) return if super_used?(node) - return if whitelist.include?(node.parent.method_name.to_s) + return if allowlist.include?(node.parent.method_name.to_s) option_hash(node) do |options| add_offense(options) @@ -37,8 +37,8 @@ def on_args(node) private - def whitelist - cop_config['Whitelist'] || [] + def allowlist + cop_config['Allowlist'] || [] end def suspicious_name?(arg_name) diff --git a/lib/rubocop/cop/style/trivial_accessors.rb b/lib/rubocop/cop/style/trivial_accessors.rb index ee9149085f0..79541e3c1e3 100644 --- a/lib/rubocop/cop/style/trivial_accessors.rb +++ b/lib/rubocop/cop/style/trivial_accessors.rb @@ -95,9 +95,9 @@ def ignore_class_methods? cop_config['IgnoreClassMethods'] end - def whitelist - whitelist = cop_config['Whitelist'] - Array(whitelist).map(&:to_sym) + [:initialize] + def allowed_methods + allowed_methods = cop_config['AllowedMethods'] + Array(allowed_methods).map(&:to_sym) + [:initialize] end def dsl_writer?(method_name) @@ -124,7 +124,7 @@ def trivial_writer?(node) PATTERN def allowed_method?(node) - whitelist.include?(node.method_name) || + allowed_methods.include?(node.method_name) || exact_name_match? && !names_match?(node) end diff --git a/manual/cops_bundler.md b/manual/cops_bundler.md index c7d2f008f70..b36941383e7 100644 --- a/manual/cops_bundler.md +++ b/manual/cops_bundler.md @@ -43,7 +43,7 @@ Include | `**/*.gemfile`, `**/Gemfile`, `**/gems.rb` | Array Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Disabled | Yes | No | 0.59 | - +Disabled | Yes | No | 0.59 | 0.77 Add a comment describing each gem in your Gemfile. @@ -65,7 +65,7 @@ gem 'foo' Name | Default value | Configurable values --- | --- | --- Include | `**/*.gemfile`, `**/Gemfile`, `**/gems.rb` | Array -Whitelist | `[]` | Array +IgnoredGems | `[]` | Array ## Bundler/InsecureProtocolSource diff --git a/manual/cops_lint.md b/manual/cops_lint.md index 1a9f87645b9..ecd1a5b222f 100644 --- a/manual/cops_lint.md +++ b/manual/cops_lint.md @@ -1908,7 +1908,7 @@ end Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | No | 0.47 | 0.56 +Enabled | Yes | No | 0.47 | 0.77 The safe navigation operator returns nil if the receiver is nil. If you chain an ordinary method call after a safe @@ -1936,13 +1936,13 @@ x&.foo || bar Name | Default value | Configurable values --- | --- | --- -Whitelist | `present?`, `blank?`, `presence`, `try`, `try!` | Array +AllowedMethods | `present?`, `blank?`, `presence`, `try`, `try!` | Array ## Lint/SafeNavigationConsistency Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | 0.55 | - +Enabled | Yes | Yes | 0.55 | 0.77 This cop check to make sure that if safe navigation is used for a method call in an `&&` or `||` condition that safe navigation is used for all @@ -1974,7 +1974,7 @@ foo&.bar && (foobar.baz || foo&.baz) Name | Default value | Configurable values --- | --- | --- -Whitelist | `present?`, `blank?`, `presence`, `try`, `try!` | Array +AllowedMethods | `present?`, `blank?`, `presence`, `try`, `try!` | Array ## Lint/SafeNavigationWithEmpty diff --git a/manual/cops_naming.md b/manual/cops_naming.md index cf6547e5daf..1b181b2dc1f 100644 --- a/manual/cops_naming.md +++ b/manual/cops_naming.md @@ -113,9 +113,9 @@ the minimum amount of characters the name must be. Its default is 1. The `AllowNamesEndingInNumbers` config option takes a boolean. When set to false, this cop will register offenses for names ending with numbers. Its default is false. The `AllowedNames` config option -takes an array of whitelisted names that will never register an +takes an array of permitted names that will never register an offense. The `ForbiddenNames` config option takes an array of -blacklisted names that will always register an offense. +restricted names that will always register an offense. ### Examples @@ -306,7 +306,7 @@ Enabled | Yes | No | 0.50 | - This cop checks that your heredocs are using meaningful delimiters. By default it disallows `END` and `EO*`, and can be configured through -blacklisting additional delimiters. +forbidden listing additional delimiters. ### Examples @@ -331,7 +331,7 @@ EOS Name | Default value | Configurable values --- | --- | --- -Blacklist | `(?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))` | Array +ForbiddenDelimiters | `(?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))` | Array ### References @@ -504,9 +504,9 @@ the minimum amount of characters the name must be. Its default is 3. The `AllowNamesEndingInNumbers` config option takes a boolean. When set to false, this cop will register offenses for names ending with numbers. Its default is false. The `AllowedNames` config option -takes an array of whitelisted names that will never register an +takes an array of permitted names that will never register an offense. The `ForbiddenNames` config option takes an array of -blacklisted names that will always register an offense. +restricted names that will always register an offense. ### Examples @@ -553,7 +553,7 @@ ForbiddenNames | `[]` | Array Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | No | 0.50 | 0.51 +Enabled | Yes | No | 0.50 | 0.77 This cop makes sure that predicates are named properly. @@ -588,8 +588,8 @@ end Name | Default value | Configurable values --- | --- | --- NamePrefix | `is_`, `has_`, `have_` | Array -NamePrefixBlacklist | `is_`, `has_`, `have_` | Array -NameWhitelist | `is_a?` | Array +ForbiddenPrefixes | `is_`, `has_`, `have_` | Array +AllowedMethods | `is_a?` | Array MethodDefinitionMacros | `define_method`, `define_singleton_method` | Array Exclude | `spec/**/*` | Array diff --git a/manual/cops_style.md b/manual/cops_style.md index 4ba53b9f27b..0e061302b70 100644 --- a/manual/cops_style.md +++ b/manual/cops_style.md @@ -2860,7 +2860,7 @@ InverseBlocks | `{:select=>:reject, :select!=>:reject!}` | Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Disabled | Yes | No | 0.58 | - +Disabled | Yes | No | 0.58 | 0.77 This cop checks for hardcoded IP addresses, which can make code brittle. IP addresses are likely to need to be changed when code @@ -2882,7 +2882,7 @@ ip_address = ENV['DEPLOYMENT_IP_ADDRESS'] Name | Default value | Configurable values --- | --- | --- -Whitelist | `::` | Array +AllowedAddresses | `::` | Array ## Style/Lambda @@ -4241,7 +4241,7 @@ something if b && a Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | 0.36 | 0.50 +Enabled | Yes | Yes | 0.36 | 0.77 This cop checks for unparenthesized method calls in the argument list of a parenthesized method call. @@ -4260,7 +4260,7 @@ method1(method2 arg, method3, arg) Name | Default value | Configurable values --- | --- | --- -Whitelist | `be`, `be_a`, `be_an`, `be_between`, `be_falsey`, `be_kind_of`, `be_instance_of`, `be_truthy`, `be_within`, `eq`, `eql`, `end_with`, `include`, `match`, `raise_error`, `respond_to`, `start_with` | Array +AllowedMethods | `be`, `be_a`, `be_an`, `be_between`, `be_falsey`, `be_kind_of`, `be_instance_of`, `be_truthy`, `be_within`, `eq`, `eql`, `end_with`, `include`, `match`, `raise_error`, `respond_to`, `start_with` | Array ## Style/NestedTernaryOperator @@ -5890,7 +5890,7 @@ EnforcedStyle | `return` | `return`, `return_nil` Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | 0.43 | 0.56 +Enabled | Yes | Yes | 0.43 | 0.77 This cop transforms usages of a method call safeguarded by a non `nil` check for the variable whose method is being called to @@ -5956,7 +5956,7 @@ foo.bar > 2 if foo Name | Default value | Configurable values --- | --- | --- ConvertCodeThatCanStartToReturnNil | `false` | Boolean -Whitelist | `present?`, `blank?`, `presence`, `try`, `try!` | Array +AllowedMethods | `present?`, `blank?`, `presence`, `try`, `try!` | Array ## Style/Sample @@ -7138,7 +7138,7 @@ AllowNamedUnderscoreVariables | `true` | Boolean Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | 0.9 | 0.38 +Enabled | Yes | Yes | 0.9 | 0.77 This cop looks for trivial reader/writer methods, that could have been created with the attr_* family of functions automatically. @@ -7176,7 +7176,7 @@ ExactNameMatch | `true` | Boolean AllowPredicates | `true` | Boolean AllowDSLWriters | `false` | Boolean IgnoreClassMethods | `false` | Boolean -Whitelist | `to_ary`, `to_a`, `to_c`, `to_enum`, `to_h`, `to_hash`, `to_i`, `to_int`, `to_io`, `to_open`, `to_path`, `to_proc`, `to_r`, `to_regexp`, `to_str`, `to_s`, `to_sym` | Array +AllowedMethod | `to_ary`, `to_a`, `to_c`, `to_enum`, `to_h`, `to_hash`, `to_i`, `to_int`, `to_io`, `to_open`, `to_path`, `to_proc`, `to_r`, `to_regexp`, `to_str`, `to_s`, `to_sym` | Array ### References diff --git a/spec/fixtures/html_formatter/expected.html b/spec/fixtures/html_formatter/expected.html index 2a6ad0ddaf6..6b0a6641d6e 100644 --- a/spec/fixtures/html_formatter/expected.html +++ b/spec/fixtures/html_formatter/expected.html @@ -574,7 +574,7 @@

RuboCop Inspection Report

Metrics/LineLength: Line is too long. [88/80] -
    # Never trust parameters from the scary internet, only allow the white list through.
+
    # Never trust parameters from the scary internet, only allow the allow list through.
diff --git a/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb b/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb index 14656a9d289..f9dafecc63a 100644 --- a/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb +++ b/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb @@ -67,7 +67,7 @@ def set_book @book = Book.find(params[:id]) end - # Never trust parameters from the scary internet, only allow the white list through. + # Never trust parameters from the scary internet, only allow the allow list through. def book_params params.require(:book).permit(:name) end diff --git a/spec/rubocop/cop/bundler/gem_comment_spec.rb b/spec/rubocop/cop/bundler/gem_comment_spec.rb index d92aa15a462..dafb4da18e0 100644 --- a/spec/rubocop/cop/bundler/gem_comment_spec.rb +++ b/spec/rubocop/cop/bundler/gem_comment_spec.rb @@ -6,7 +6,7 @@ let(:cop_config) do { 'Include' => ['**/Gemfile'], - 'Whitelist' => ['rake'] + 'IgnoredGems' => ['rake'] } end @@ -34,7 +34,7 @@ end end - context 'and the gem is whitelisted' do + context 'and the gem is permitted' do it 'does not register any offenses' do expect_no_offenses(<<~RUBY, 'Gemfile') gem 'rake' diff --git a/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb b/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb index efa62c7b4f4..7391c94dc5d 100644 --- a/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb +++ b/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb @@ -4,7 +4,7 @@ subject(:cop) { described_class.new(config) } let(:cop_config) do - { 'Whitelist' => %w[present? blank? try presence] } + { 'AcceptedMethods' => %w[present? blank? try presence] } end shared_examples 'accepts' do |name, code| diff --git a/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb b/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb index 2cb80184eed..d39d56104cd 100644 --- a/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb +++ b/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb @@ -4,7 +4,7 @@ subject(:cop) { described_class.new(config) } let(:cop_config) do - { 'Whitelist' => %w[present? blank? try presence] } + { 'AllowedMethods' => %w[present? blank? try presence] } end it 'allows && without safe navigation' do diff --git a/spec/rubocop/cop/metrics/line_length_spec.rb b/spec/rubocop/cop/metrics/line_length_spec.rb index b99b50ce335..b2a4e3bf35f 100644 --- a/spec/rubocop/cop/metrics/line_length_spec.rb +++ b/spec/rubocop/cop/metrics/line_length_spec.rb @@ -167,7 +167,7 @@ def test_some_other_long_test_description_which_exceeds_length end end - context 'and only certain heredoc delimiters are whitelisted' do + context 'and only certain heredoc delimiters are permitted' do let(:cop_config) do { 'Max' => 80, 'AllowHeredoc' => %w[SQL OK], 'IgnoredPatterns' => [] } end @@ -176,25 +176,25 @@ def test_some_other_long_test_description_which_exceeds_length foo(<<-DOC, <<-SQL, <<-FOO) 1st offense: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \#{<<-OK} - no offense (whitelisted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + no offense (permitted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. OK 2nd offense: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. DOC - no offense (whitelisted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + no offense (permitted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \#{<<-XXX} - no offense (nested inside whitelisted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + no offense (nested inside permitted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. XXX - no offense (whitelisted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + no offense (permitted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. SQL 3rd offense: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \#{<<-SQL} - no offense (whitelisted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + no offense (permitted): Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. SQL 4th offense: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. FOO RUBY - it 'rejects long lines in heredocs with not whitelisted delimiters' do + it 'rejects long lines in heredocs with not permitted delimiters' do inspect_source(source) expect(cop.offenses.size).to eq(4) end diff --git a/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb b/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb index 1a6273b2d6b..578a971b96c 100644 --- a/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb +++ b/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb @@ -8,7 +8,7 @@ end let(:cop_config) do - { 'Blacklist' => %w[END] } + { 'ForbiddenDelimiters' => %w[END] } end context 'with an interpolated heredoc' do diff --git a/spec/rubocop/cop/naming/predicate_name_spec.rb b/spec/rubocop/cop/naming/predicate_name_spec.rb index 88657c9aee1..986d2922ff2 100644 --- a/spec/rubocop/cop/naming/predicate_name_spec.rb +++ b/spec/rubocop/cop/naming/predicate_name_spec.rb @@ -3,10 +3,10 @@ RSpec.describe RuboCop::Cop::Naming::PredicateName, :config do subject(:cop) { described_class.new(config) } - context 'with blacklisted prefixes' do + context 'with restricted prefixes' do let(:cop_config) do { 'NamePrefix' => %w[has_ is_], - 'NamePrefixBlacklist' => %w[has_ is_] } + 'ForbiddenPrefixes' => %w[has_ is_] } end it 'registers an offense when method name starts with "is"' do @@ -42,9 +42,9 @@ def is_2d?; end end end - context 'without blacklisted prefixes' do + context 'without restricted prefixes' do let(:cop_config) do - { 'NamePrefix' => %w[has_ is_], 'NamePrefixBlacklist' => [] } + { 'NamePrefix' => %w[has_ is_], 'ForbiddenPrefixes' => [] } end it 'registers an offense when method name starts with "is"' do @@ -74,13 +74,13 @@ def is_2d?; end end end - context 'with whitelisted predicate names' do + context 'with permitted predicate names' do let(:cop_config) do - { 'NamePrefix' => %w[is_], 'NamePrefixBlacklist' => %w[is_], - 'NameWhitelist' => %w[is_a?] } + { 'NamePrefix' => %w[is_], 'ForbiddenPrefixes' => %w[is_], + 'AllowedMethods' => %w[is_a?] } end - it 'accepts method name which is in whitelist' do + it 'accepts method name which is in permitted list' do expect_no_offenses(<<~RUBY) def is_a?; end RUBY @@ -89,7 +89,7 @@ def is_a?; end context 'with method definition macros' do let(:cop_config) do - { 'NamePrefix' => %w[is_], 'NamePrefixBlacklist' => %w[is_], + { 'NamePrefix' => %w[is_], 'ForbiddenPrefixes' => %w[is_], 'MethodDefinitionMacros' => %w[define_method def_node_matcher] } end @@ -124,7 +124,7 @@ def is_a?; end context 'without method definition macros' do let(:cop_config) do - { 'NamePrefix' => %w[is_], 'NamePrefixBlacklist' => %w[is_] } + { 'NamePrefix' => %w[is_], 'ForbiddenPrefixes' => %w[is_] } end it 'registers an offense when using `define_method`' do diff --git a/spec/rubocop/cop/style/global_vars_spec.rb b/spec/rubocop/cop/style/global_vars_spec.rb index a0fde2fd025..f81d86524ca 100644 --- a/spec/rubocop/cop/style/global_vars_spec.rb +++ b/spec/rubocop/cop/style/global_vars_spec.rb @@ -16,7 +16,7 @@ RUBY end - it 'allows user whitelisted variables' do + it 'allows user permitted variables' do expect_no_offenses('puts $allowed') end diff --git a/spec/rubocop/cop/style/ip_addresses_spec.rb b/spec/rubocop/cop/style/ip_addresses_spec.rb index a722bac3a37..ca7f6f71ac3 100644 --- a/spec/rubocop/cop/style/ip_addresses_spec.rb +++ b/spec/rubocop/cop/style/ip_addresses_spec.rb @@ -71,8 +71,8 @@ expect_no_offenses('"::"') end - context 'when it is removed from the whitelist' do - let(:cop_config) { { 'Whitelist' => [] } } + context 'when it is removed from the allowed addresses' do + let(:cop_config) { { 'AllowedAddresses' => [] } } it 'registers an offense' do expect_offense(<<~RUBY) @@ -84,10 +84,10 @@ end end - context 'with whitelist' do - let(:cop_config) { { 'Whitelist' => ['a::b'] } } + context 'with allowed addresses' do + let(:cop_config) { { 'AllowedAddresses' => ['a::b'] } } - it 'does not register an offense for a whitelisted address' do + it 'does not register an offense for a allowed addresses' do expect_no_offenses('"a::b"') end diff --git a/spec/rubocop/cop/style/nested_parenthesized_calls_spec.rb b/spec/rubocop/cop/style/nested_parenthesized_calls_spec.rb index 31cd8986ce6..aeb62378a7d 100644 --- a/spec/rubocop/cop/style/nested_parenthesized_calls_spec.rb +++ b/spec/rubocop/cop/style/nested_parenthesized_calls_spec.rb @@ -5,7 +5,7 @@ let(:config) do RuboCop::Config.new( - 'Style/NestedParenthesizedCalls' => { 'Whitelist' => ['be'] } + 'Style/NestedParenthesizedCalls' => { 'AllowedMethods' => ['be'] } ) end @@ -89,7 +89,7 @@ end end - context 'on a whitelisted method' do + context 'on a permitted method' do it "doesn't register an offense" do expect_no_offenses('expect(obj).to(be true)') end diff --git a/spec/rubocop/cop/style/option_hash_spec.rb b/spec/rubocop/cop/style/option_hash_spec.rb index c95a2372738..e4546b37ddc 100644 --- a/spec/rubocop/cop/style/option_hash_spec.rb +++ b/spec/rubocop/cop/style/option_hash_spec.rb @@ -91,10 +91,10 @@ def allowed(foo, options = {}) end end - context 'whitelist' do - let(:cop_config) { { 'Whitelist' => %w[to_json] } } + context 'permitted list' do + let(:cop_config) { { 'Allowlist' => %w[to_json] } } - it 'ignores if the method is whitelisted' do + it 'ignores if the method is permitted' do expect_no_offenses(<<~RUBY) def to_json(options = {}) end diff --git a/spec/rubocop/cop/style/safe_navigation_spec.rb b/spec/rubocop/cop/style/safe_navigation_spec.rb index a67f99a2741..c7139b56d7a 100644 --- a/spec/rubocop/cop/style/safe_navigation_spec.rb +++ b/spec/rubocop/cop/style/safe_navigation_spec.rb @@ -48,7 +48,7 @@ it 'allows an object check before a blank check' do # The `nil` object doesn't respond to `blank?` in normal Ruby (it's added - # by Rails), but it's included in the Whitelist parameter in default + # by Rails), but it's included in the AllowedMethods parameter in default # configuration for this cop. expect_no_offenses('user && user.thing.blank?') end diff --git a/spec/rubocop/cop/style/trivial_accessors_spec.rb b/spec/rubocop/cop/style/trivial_accessors_spec.rb index 2353e2b52b1..cb74224d759 100644 --- a/spec/rubocop/cop/style/trivial_accessors_spec.rb +++ b/spec/rubocop/cop/style/trivial_accessors_spec.rb @@ -410,10 +410,10 @@ def foo? end end - context 'with whitelist' do - let(:cop_config) { { 'Whitelist' => ['to_foo', 'bar='] } } + context 'with allowed methods' do + let(:cop_config) { { 'AllowedMethods' => ['to_foo', 'bar='] } } - it 'accepts whitelisted reader' do + it 'accepts allowed reader' do expect_no_offenses(<<~RUBY) class Foo def to_foo @@ -423,7 +423,7 @@ def to_foo RUBY end - it 'accepts whitelisted writer' do + it 'accepts allowed writer' do expect_no_offenses(<<~RUBY) class Foo def bar=(bar) @@ -436,10 +436,10 @@ def bar=(bar) context 'with AllowPredicates: false' do let(:cop_config) do { 'AllowPredicates' => false, - 'Whitelist' => ['foo?'] } + 'AllowedMethods' => ['foo?'] } end - it 'accepts whitelisted predicate' do + it 'accepts allowed predicate' do expect_no_offenses(<<~RUBY) class Foo def foo?