File tree Expand file tree Collapse file tree 4 files changed +15
-30
lines changed Expand file tree Collapse file tree 4 files changed +15
-30
lines changed Original file line number Diff line number Diff line change 22
33module RuboCop
44 module Cop
5- WorkaroundCop = Cop . dup
6-
7- # Clone of the the normal RuboCop::Cop::Cop class so we can rewrite
8- # the inherited method without breaking functionality
9- class WorkaroundCop
10- # Remove the Cop.inherited method to be a noop. Our RSpec::Cop
11- # class will invoke the inherited hook instead
12- class << self
13- undef inherited
14- def inherited ( *) end
15- end
16-
17- # Special case `Module#<` so that the rspec support rubocop exports
18- # is compatible with our subclass
19- def self . <( other )
20- other . equal? ( RuboCop ::Cop ::Cop ) || super
21- end
22- end
23- private_constant ( :WorkaroundCop )
24-
255 module RSpec
266 # @abstract parent class to rspec cops
277 #
@@ -37,7 +17,7 @@ module RSpec
3717 # Patterns:
3818 # - '_test.rb$'
3919 # - '(?:^|/)test/'
40- class Cop < WorkaroundCop
20+ class Cop < :: RuboCop :: Cop :: Cop
4121 include RuboCop ::RSpec ::Language
4222 include RuboCop ::RSpec ::Language ::NodePattern
4323
Original file line number Diff line number Diff line change @@ -68,10 +68,8 @@ def documented_constant
6868 end
6969
7070 def cop_subclass?
71- # YARD superclass resolution is a bit flaky: All classes loaded before
72- # RuboCop::Cop::WorkaroundCop are shown as having RuboCop::Cop as
73- # superclass, while all the following classes are listed as having
74- # RuboCop::Cop::RSpec::Cop as their superclass.
71+ # FIXME: simplify
72+
7573 COP_CLASS_NAMES . include? ( yardoc . superclass . path )
7674 end
7775
Original file line number Diff line number Diff line change 2020 end
2121
2222 let ( :fake_cop ) do
23- stub_const ( 'RuboCop::RSpec' , Module . new )
2423 # rubocop:disable Style/ClassAndModuleChildren
2524 # rubocop:disable RSpec/LeakyConstantDeclaration
2625 class RuboCop ::RSpec ::FakeCop < described_class
Original file line number Diff line number Diff line change @@ -42,11 +42,19 @@ def bar
4242 YARD ::Registry . all
4343 end
4444
45+ let ( :temp_class ) do
46+ temp = RuboCop ::Cop ::Cop . dup
47+ temp . class_exec do
48+ class << self
49+ undef inherited
50+ def inherited ( *) end
51+ end
52+ end
53+ temp
54+ end
55+
4556 def stub_cop_const ( name )
46- stub_const (
47- "RuboCop::Cop::RSpec::#{ name } " ,
48- Class . new ( RuboCop ::Cop . const_get ( :WorkaroundCop ) )
49- )
57+ stub_const ( "RuboCop::Cop::RSpec::#{ name } " , Class . new ( temp_class ) )
5058 end
5159
5260 before do
You can’t perform that action at this time.
0 commit comments