Class: RuboCop::Cop::Salsify::RspecDotNotSelfDot
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Salsify::RspecDotNotSelfDot
- 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
#autocorrect(node) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb', line 35 def autocorrect(node) lambda do |corrector| corrector.remove(Parser::Source::Range.new(node.source_range.source_buffer, node.source_range.begin_pos + 1, node.source_range.begin_pos + 5)) end end |
#on_send(node) ⇒ Object
29 30 31 32 33 |
# File 'lib/rubocop/cop/salsify/rspec_dot_not_self_dot.rb', line 29 def on_send(node) example_group_match(node) do |doc| add_offense(doc) if SELF_DOT_REGEXP.match?(doc.source) end end |