Skip to content

Commit

Permalink
Merge pull request #468 from meatballhat/accept-vim-style-encoding-co…
Browse files Browse the repository at this point in the history
…mments

Allow vim-style magic encoding comments
  • Loading branch information
bbatsov committed Sep 8, 2013
2 parents f67476d + d026811 commit 5793f16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def investigate(processed_source)
line_number = 0
line_number += 1 if processed_source[line_number] =~ /^#!/
line = processed_source[line_number]
unless line =~ /#.*coding\s?: (UTF|utf)-8/
unless line =~ /#.*coding\s?[:=]\s?(UTF|utf)-8/
convention(nil,
source_range(processed_source.buffer,
processed_source[0...line_number],
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/style/encoding_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ module Style

expect(encoding.messages).to be_empty
end

it 'accepts vim-style encoding comments', ruby: 1.9 do
inspect_source(encoding, ['# vim:fileencoding=utf-8',
'def foo() end'])
expect(encoding.messages).to be_empty
end
end
end
end
Expand Down

0 comments on commit 5793f16

Please sign in to comment.