Class: Rubocop::Cop::Encoding
- Defined in:
- lib/rubocop/cop/encoding.rb
Constant Summary collapse
- MSG =
'Missing utf-8 encoding comment.'
Instance Attribute Summary
Attributes inherited from Cop
#debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, cop_name, #has_report?, inherited, #initialize, #name, #on_comment
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(source, tokens, ast, comments) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/rubocop/cop/encoding.rb', line 8 def inspect(source, tokens, ast, comments) unless RUBY_VERSION >= '2.0.0' expected_line = 0 expected_line += 1 if source[expected_line] =~ /^#!/ unless source[expected_line] =~ /#.*coding: (UTF|utf)-8/ add_offence(:convention, 1, MSG) end end end |