Sha256: 2e9aabe27a71304c82d9154bb9fba6fe887015792a4780cbadb02d3ab5f61c6d
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'pluginscan/reports/issues_report/issues_scanner/file_issues_scanner' require 'pluginscan/reports/issues_report/issues_scanner/line_issues_scanner' require 'pluginscan/reports/issues_report/issues_scanner/utf8_checker' require 'pluginscan/reports/issues_report/issues_models/check_findings' require 'pluginscan/reports/issues_report/issues_models/issues' module Pluginscan class IssuesScanner def initialize(checks) file_issues_scanner = FileIssuesScanner.new(checks) @file_scanner = FileScanner.new(file_issues_scanner) end def scan(files) issues = scan_files(files) Issues.new(issues) end private def scan_files(file_paths) file_paths.inject({}) do |issues, file_path| issues.merge file_path => scan_file(file_path) end end def scan_file(file_path) file_contents = File.read(file_path) @file_scanner.scan(file_contents) end end # Responsible for checking that a file's contents is valid # and if so, running an issues scan on it class FileScanner def initialize(issues_scanner) @issues_scanner = issues_scanner end def scan(file_contents) # Check file contents are valid UTF-8 to avoid exceptions later invalid_utf8 = UTF8Checker.new.check(file_contents) return Array(invalid_utf8) if invalid_utf8 @issues_scanner.scan(file_contents) 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.rb |