diff --git a/.rubocop.yml b/.rubocop.yml index 211ada70f..d7125963f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,3 @@ -inherit_from: .rubocop_todo.yml - require: - rubocop-performance - rubocop-rake diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 2941286be..000000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2020-07-15 15:15:30 UTC using RuboCop version 0.87.0. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 1 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ClassLength: - Max: 106 - -RSpec/ExampleLength: - Exclude: - - spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb diff --git a/lib/rubocop/cop/rspec/described_class.rb b/lib/rubocop/cop/rspec/described_class.rb index 05b646ae6..bba1d3c46 100644 --- a/lib/rubocop/cop/rspec/described_class.rb +++ b/lib/rubocop/cop/rspec/described_class.rb @@ -78,9 +78,8 @@ class DescribedClass < Base PATTERN # @!method contains_described_class?(node) - def_node_search :contains_described_class?, <<-PATTERN - (send nil? :described_class) - PATTERN + def_node_search :contains_described_class?, + '(send nil? :described_class)' def on_block(node) # In case the explicit style is used, we need to remember what's @@ -129,17 +128,13 @@ def message(offense) end def scope_change?(node) - scope_changing_syntax?(node) || + scope_changing_syntax?(node) || common_instance_exec_closure?(node) || skippable_block?(node) end def skippable_block?(node) - node.block_type? && !rspec_block?(node) && skip_blocks? - end - - def skip_blocks? - cop_config['SkipBlocks'] + node.block_type? && !rspec_block?(node) && cop_config['SkipBlocks'] end def offensive?(node) @@ -152,6 +147,7 @@ def offensive?(node) def offensive_described_class?(node) return unless node.const_type? + # E.g. `described_class::CONSTANT` return if contains_described_class?(node) @@ -172,14 +168,13 @@ def full_const_name(node) # @return [Array] # @example # # nil represents base constant - # collapse_namespace([], :C) # => [:C] - # collapse_namespace([:A, :B], [:C) # => [:A, :B, :C] - # collapse_namespace([:A, :B], [:B, :C) # => [:A, :B, :C] - # collapse_namespace([:A, :B], [nil, :C) # => [nil, :C] - # collapse_namespace([:A, :B], [nil, :B, :C) # => [nil, :B, :C] + # collapse_namespace([], [:C]) # => [:C] + # collapse_namespace([:A, :B], [:C]) # => [:A, :B, :C] + # collapse_namespace([:A, :B], [:B, :C]) # => [:A, :B, :C] + # collapse_namespace([:A, :B], [nil, :C]) # => [nil, :C] + # collapse_namespace([:A, :B], [nil, :B, :C]) # => [nil, :B, :C] def collapse_namespace(namespace, const) - return const if namespace.empty? - return const if const.first.nil? + return const if namespace.empty? || const.first.nil? start = [0, (namespace.length - const.length)].max max = namespace.length @@ -196,9 +191,7 @@ def collapse_namespace(namespace, const) # const_name(s(:const, s(:const, nil, :M), :C)) # => [:M, :C] # const_name(s(:const, s(:cbase), :C)) # => [nil, :C] def const_name(node) - # rubocop:disable InternalAffairs/NodeDestructuring - namespace, name = *node - # rubocop:enable InternalAffairs/NodeDestructuring + namespace, name = *node # rubocop:disable InternalAffairs/NodeDestructuring if !namespace [name] elsif namespace.const_type?