Class: Tailor::Rulers::AllowUnnecessaryDoubleQuotesRuler
- Inherits:
-
Tailor::Ruler
- Object
- Tailor::Ruler
- Tailor::Rulers::AllowUnnecessaryDoubleQuotesRuler
- Defined in:
- lib/tailor/rulers/allow_unnecessary_double_quotes_ruler.rb
Instance Attribute Summary
Attributes inherited from Tailor::Ruler
Instance Method Summary collapse
-
#initialize(config, options) ⇒ AllowUnnecessaryDoubleQuotesRuler
constructor
A new instance of AllowUnnecessaryDoubleQuotesRuler.
-
#measure(lineno, column) ⇒ Object
Checks to see if the double_quotes are unnecessary.
- #nl_update(lexed_line, lineno, _) ⇒ Object
Methods inherited from Tailor::Ruler
#add_child_ruler, #problem_type, #problems
Methods included from Logger::Mixin
Constructor Details
#initialize(config, options) ⇒ AllowUnnecessaryDoubleQuotesRuler
Returns a new instance of AllowUnnecessaryDoubleQuotesRuler.
6 7 8 9 |
# File 'lib/tailor/rulers/allow_unnecessary_double_quotes_ruler.rb', line 6 def initialize(config, ) super(config, ) add_lexer_observers :nl end |
Instance Method Details
#measure(lineno, column) ⇒ Object
Checks to see if the double_quotes are unnecessary.
24 25 26 27 28 |
# File 'lib/tailor/rulers/allow_unnecessary_double_quotes_ruler.rb', line 24 def measure(lineno, column) @problems << Problem.new('unnecessary_double_quotes', lineno, column, "Unnecessary double quotes at column #{column}, " + 'expected single quotes.', @options[:level]) end |
#nl_update(lexed_line, lineno, _) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/tailor/rulers/allow_unnecessary_double_quotes_ruler.rb', line 11 def nl_update(lexed_line, lineno, _) quotes(lexed_line).each do |quote| unless (quote) || contains_escape_sequence?(quote) measure(lineno, column(quote.first)) end end end |