module Pluginscan # Responsible for checking a file for utf-8 validity class UTF8Checker # TODO: This returns nil if the file was valid. Returning nil is bad. def check(file_contents) # Check file contents are valid UTF-8 file_contents.force_encoding('utf-8') return if file_contents.valid_encoding? CheckFindings.new( Check.new(name: 'Encoding', message: 'invalid UTF-8') ) end end end