Commit 8d2996e
committed
Fix implicit subjects mocked/stubbed not detected
[Implicit Subject](https://relishapp.com/rspec/rspec-core/v/3-8/docs/subject/implicitly-defined-subject)
had not been detected by the `Rspec/SubjectStub`, which reported false
negative cases.
As suggested by [@pirij][], there are solutions to recursively traverse
through AST (either upward or downward). However, to the best of my
knowledge, they might require a fair amount of changes how the
cop is currently working and impact the runtime performance.
I've chosen the somewhat safe fix that reports the defaut `:subject` if there is no
named nor unnamed subject declared.1 parent abdb94a commit 8d2996e
File tree
3 files changed
+17
-1
lines changed- lib/rubocop/cop/rspec
- spec/rubocop/cop/rspec
3 files changed
+17
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| 459 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
293 | 304 | | |
0 commit comments