File tree 3 files changed +27
-2
lines changed
3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Master (Unreleased)
4
4
5
+ - Fix a false positive for ` RSpec/DescribedClass ` when ` SkipBlocks ` is true and numblocks are used. ([ @earlopain ] )
6
+
5
7
## 3.5.0 (2025-02-16)
6
8
7
9
- Don't let ` RSpec/PredicateMatcher ` replace ` respond_to? ` with two arguments with the RSpec ` respond_to ` matcher. ([ @bquorning ] )
Original file line number Diff line number Diff line change @@ -153,7 +153,9 @@ def scope_change?(node)
153
153
end
154
154
155
155
def skippable_block? ( node )
156
- node . block_type? && !rspec_block? ( node ) && cop_config [ 'SkipBlocks' ]
156
+ return false unless cop_config [ 'SkipBlocks' ]
157
+
158
+ node . any_block_type? && !rspec_block? ( node )
157
159
end
158
160
159
161
def only_static_constants?
Original file line number Diff line number Diff line change 10
10
expect_offense ( <<~RUBY )
11
11
describe MyClass do
12
12
controller(ApplicationController) do
13
- bar = MyClass
13
+ self.bar = MyClass
14
+ end
15
+
16
+ before do
17
+ MyClass
18
+ ^^^^^^^ Use `described_class` instead of `MyClass`.
19
+
20
+ Foo.custom_block do
21
+ MyClass
22
+ end
23
+ end
24
+ end
25
+ RUBY
26
+ end
27
+
28
+ it 'ignores offenses within non-rspec numblocks' do
29
+ expect_offense ( <<~RUBY )
30
+ describe MyClass do
31
+ controller(ApplicationController) do
32
+ do_some_work(_1)
33
+ self.bar = MyClass
14
34
end
15
35
16
36
before do
17
37
MyClass
18
38
^^^^^^^ Use `described_class` instead of `MyClass`.
19
39
20
40
Foo.custom_block do
41
+ do_some_work(_1)
21
42
MyClass
22
43
end
23
44
end
You can’t perform that action at this time.
0 commit comments