module Pluginscan # Wraps a couple of helper methods around an array of issues class Issues include Enumerable def initialize(issues) @issues = issues end def each(&block) @issues.each(&block) end def scanned_files_count @issues.count end def found_problems_count found_problems.reduce(0){ |count, (_file, file_findings)| count + file_findings.map(&:count).reduce(:+) } end private def files @issues.keys end private def found_problems # Ignore files which didn't have any problems Issues.new(@issues.select { |_file, file_findings| !file_findings.empty? }) end end end