Class: Shirobai::Cop::RSpec::RepeatedExample
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Shirobai::Cop::RSpec::RepeatedExample
- Includes:
- RuboCop::Cop::RSpec::RepeatedItems, BundleEligible
- Defined in:
- lib/shirobai/cop/rspec/repeated_example.rb
Overview
Drop-in Rust reimplementation of RSpec/RepeatedExample
(rubocop-rspec 3.10.2).
Same split as RSpec/RepeatedDescription: Rust collects each example
group's examples on the shared walk and puts the example BLOCK node
ranges of every group with >= 2 examples on the wire (identical data to
RepeatedDescription — each cop owns its slot). The wrapper relocates the
parser nodes, wraps them in the stock RuboCop::RSpec::Example, includes
stock's RepeatedItems mixin, and runs find_repeated_groups VERBATIM.
The signature is [metadata, implementation] (plus definition.arguments
for its), compared by parser-node structural equality — so quote-style
and paren differences are repeats while a dstr and a heredoc body are
not, all decided on real nodes rather than bytewise.
Constant Summary collapse
- MSG =
"Don't repeat examples within an example group. " \ "Repeated on line(s) %<lines>s."
Class Method Summary collapse
- .badge ⇒ Object
-
.bundle_args(_config) ⇒ Object
Config-less (the segment's role lists cover everything).
- .cop_name ⇒ Object
Instance Method Summary collapse
Class Method Details
.badge ⇒ Object
27 |
# File 'lib/shirobai/cop/rspec/repeated_example.rb', line 27 def self.badge = RuboCop::Cop::Badge.parse(cop_name) |
.bundle_args(_config) ⇒ Object
Config-less (the segment's role lists cover everything).
30 31 32 |
# File 'lib/shirobai/cop/rspec/repeated_example.rb', line 30 def self.bundle_args(_config) [] end |
.cop_name ⇒ Object
26 |
# File 'lib/shirobai/cop/rspec/repeated_example.rb', line 26 def self.cop_name = "RSpec/RepeatedExample" |
Instance Method Details
#on_new_investigation ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/shirobai/cop/rspec/repeated_example.rb', line 34 def on_new_investigation groups = resolved_groups return if groups.empty? source = bundle_eligible? ? processed_source.raw_source : processed_source.buffer.source off = SourceOffsets.for(source) located = locate_blocks(groups, off) groups.each do |ranges| examples = examples_for(ranges, off, located) next if examples.length < 2 find_repeated_examples(examples).each do |repeated_examples| add_offenses_for_repeated_group(repeated_examples) end end end |