Class: Codeqa::Checkers::CheckUtf8Encoding

Inherits:
Codeqa::Checker show all
Defined in:
lib/codeqa/checkers/check_utf8_encoding.rb

Instance Attribute Summary

Attributes inherited from Codeqa::Checker

#errors, #sourcefile

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Codeqa::Checker

available?, #initialize

Constructor Details

This class inherits a constructor from Codeqa::Checker

Class Method Details

.check?(sourcefile) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/codeqa/checkers/check_utf8_encoding.rb', line 4

def self.check?(sourcefile)
  sourcefile.text?
end

Instance Method Details

#checkObject



16
17
18
19
# File 'lib/codeqa/checkers/check_utf8_encoding.rb', line 16

def check
  return if sourcefile.content.force_encoding('UTF-8').valid_encoding?
  errors.add(nil, 'encoding error, not utf8')
end

#hintObject



12
13
14
# File 'lib/codeqa/checkers/check_utf8_encoding.rb', line 12

def hint
  'The file contains non utf8 characters. Find and remove them.'
end

#nameObject



8
9
10
# File 'lib/codeqa/checkers/check_utf8_encoding.rb', line 8

def name
  'utf8 encoding'
end