Sha256: 51303a46c6c6ef26555aea3242e55d2a77b5afc13e37c0d72315e1316817cc8b

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'stringio'

module Pluginscan
  # Responsible for scanning a file for a set of issue types
  class FileIssuesScanner
    attr_reader :file_results

    def initialize(checks)
      @checks = checks
    end

    # Returns an array of CheckFindings objects
    def scan(file_contents)
      # Run each check on the file
      checks_findings = @checks.map { |check| LinesIssuesScanner.new(check).scan(file_contents) }
      checks_findings.select(&:any_findings?)
    end
  end
end

module Pluginscan
  # Responsible for scanning each line of a file for issues of a certain type
  class LinesIssuesScanner
    def initialize(check)
      @line_issues_scanner = LineIssuesScanner.new(check)
      @check_findings = CheckFindings.new(check)
    end

    def scan(file_contents)
      string_io = StringIO.new(file_contents)
      @check_findings.tap do |check_findings|
        string_io.each_line do |line|
          check_findings.add @line_issues_scanner.scan(line, string_io.lineno)
        end
      end
    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/file_issues_scanner.rb