Module: RuboCop::Cop::StringHelp
- Included in:
- RuboCop::Cop::Style::CharacterLiteral, RuboCop::Cop::Style::IpAddresses, RuboCop::Cop::Style::StringLiterals, RuboCop::Cop::Style::StringLiteralsInInterpolation
- Defined in:
- lib/rubocop/cop/mixin/string_help.rb
Overview
Classes that include this module just implement functions to determine what is an offense and how to do autocorrection. They get help with adding offenses for the faulty string nodes, and with filtering out nodes.
Instance Method Summary collapse
Instance Method Details
permalink #on_regexp(node) ⇒ Object
[View source]
26 27 28 |
# File 'lib/rubocop/cop/mixin/string_help.rb', line 26 def on_regexp(node) ignore_node(node) end |
permalink #on_str(node) ⇒ Object
[View source]
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rubocop/cop/mixin/string_help.rb', line 10 def on_str(node) # Constants like __FILE__ are handled as strings, # but don't respond to begin. return unless node.loc?(:begin) return if part_of_ignored_node?(node) if offense?(node) add_offense(node) do |corrector| opposite_style_detected autocorrect(corrector, node) if respond_to?(:autocorrect, true) end else correct_style_detected end end |