This cop checks whether the source file has a utf-8 encoding comment or not. This check makes sense only in Ruby 1.9, since in 2.0+ utf-8 is the default source file encoding. There are two style:
when_needed - only enforce an encoding comment if there are non ASCII
characters, otherwise report an offense
always - enforce encoding comment in all files
# File lib/rubocop/cop/style/encoding.rb, line 18 def investigate(processed_source) return if RUBY_VERSION >= '2.0.0' return if processed_source.buffer.source.empty? line_number = encoding_line_number(processed_source) message = offense(processed_source, line_number) return unless message add_offense(nil, source_range(processed_source.buffer, processed_source[0...line_number], 0, 1), message) end
Generated with the Darkfish Rdoc Generator 2.