Class: RuboCop::Cop::Ezcater::RspecDotNotSelfDot
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Ezcater::RspecDotNotSelfDot
- Defined in:
- lib/rubocop/cop/ezcater/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\./
- MSG =
'Use ".<class method>" instead of "self.<class method>" for example group description.'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb', line 32 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
26 27 28 29 30 |
# File 'lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb', line 26 def on_send(node) example_group_match(node) do |doc| add_offense(doc, :expression, MSG) if doc.source.match?(SELF_DOT_REGEXP) end end |