Skip to content

Commit 9de232b

Browse files
authored
Merge pull request #1722 from drcapulet/alexc-repeated-subject-calls
Add new RSpec/RepeatedSubjectCall cop
2 parents c998f1e + 2c903d6 commit 9de232b

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ RSpec/RedundantPredicateMatcher:
181181
Enabled: true
182182
RSpec/RemoveConst:
183183
Enabled: true
184+
RSpec/RepeatedSubjectCall:
185+
Enabled: true
184186
RSpec/SkipBlockInsideExample:
185187
Enabled: true
186188
RSpec/SortMetadata:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Support correcting `assert_nil` and `refute_nil` to `RSpec/Rails/MinitestAssertions`. ([@G-Rath])
66
- Fix a false positive for `RSpec/ExpectActual` when used with rspec-rails routing matchers. ([@naveg])
7+
- Add new `RSpec/RepeatedSubjectCall` cop. ([@drcapulet])
78

89
## 2.26.1 (2024-01-05)
910

@@ -848,6 +849,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
848849
[@deivid-rodriguez]: https://github.com/deivid-rodriguez
849850
[@dgollahon]: https://github.com/dgollahon
850851
[@dmitrytsepelev]: https://github.com/dmitrytsepelev
852+
[@drcapulet]: https://github.com/drcapulet
851853
[@drowze]: https://github.com/Drowze
852854
[@dswij]: https://github.com/dswij
853855
[@dvandersluis]: https://github.com/dvandersluis

config/default.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,12 @@ RSpec/RepeatedIncludeExample:
813813
VersionAdded: '1.44'
814814
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedIncludeExample
815815

816+
RSpec/RepeatedSubjectCall:
817+
Description: Checks for repeated calls to subject missing that it is memoized.
818+
Enabled: pending
819+
VersionAdded: "<<next>>"
820+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedSubjectCall
821+
816822
RSpec/ReturnFromStub:
817823
Description: Checks for consistent style of stub's return setting.
818824
Enabled: true

docs/modules/ROOT/pages/cops.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
* xref:cops_rspec.adoc#rspecrepeatedexamplegroupbody[RSpec/RepeatedExampleGroupBody]
8888
* xref:cops_rspec.adoc#rspecrepeatedexamplegroupdescription[RSpec/RepeatedExampleGroupDescription]
8989
* xref:cops_rspec.adoc#rspecrepeatedincludeexample[RSpec/RepeatedIncludeExample]
90+
* xref:cops_rspec.adoc#rspecrepeatedsubjectcall[RSpec/RepeatedSubjectCall]
9091
* xref:cops_rspec.adoc#rspecreturnfromstub[RSpec/ReturnFromStub]
9192
* xref:cops_rspec.adoc#rspecscatteredlet[RSpec/ScatteredLet]
9293
* xref:cops_rspec.adoc#rspecscatteredsetup[RSpec/ScatteredSetup]

lib/rubocop/cop/rspec_rails_cops.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
require_relative 'rspec/repeated_example_group_body'
114114
require_relative 'rspec/repeated_example_group_description'
115115
require_relative 'rspec/repeated_include_example'
116+
require_relative 'rspec/repeated_subject_call'
116117
require_relative 'rspec/return_from_stub'
117118
require_relative 'rspec/scattered_let'
118119
require_relative 'rspec/scattered_setup'

0 commit comments

Comments
 (0)