Sha256: e8f77981dcfab64ff0458b81d339f88cd5d37cbb0a10af64fb65e101a5c4268f

Contents?: true

Size: 443 Bytes

Versions: 1

Compression:

Stored size: 443 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pluginscan-0.9.0 lib/pluginscan/reports/issues_report/issues_scanner/utf8_checker.rb