Class: RuboCop::Cop::Salsify::RspecDotNotSelfDot
- Inherits:
-
RSpec::Base
- Object
- RSpec::Base
- RuboCop::Cop::Salsify::RspecDotNotSelfDot
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb
Overview
Use “.<class method>” instead of “self.<class method>” in RSpec example group descriptions.
Constant Summary collapse
- SELF_DOT_REGEXP =
/["']self\./.freeze
- MSG =
'Use ".<class method>" instead of "self.<class method>" for example group description.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb', line 30 def on_send(node) example_group_match(node) do |doc| next unless SELF_DOT_REGEXP.match?(doc.source) add_offense(doc) do |corrector| corrector.remove(Parser::Source::Range.new(doc.source_range.source_buffer, doc.source_range.begin_pos + 1, doc.source_range.begin_pos + 5)) end end end |