Sha256: 5e488157c91da02e9b0dc3211486e8a1fe2194942dc148f949c5c1691846a4b0
Contents?: true
Size: 1.05 KB
Versions: 8
Compression:
Stored size: 1.05 KB
Contents
module Codacy module Parser def self.parse_file(simplecov_result) project_dir = Codacy::Git.work_dir logger.info("Parsing simplecov result to Codacy format...") logger.debug(simplecov_result.original_result) file_reports = simplecov_result.original_result.map do |k, v| file_dir = k.sub(project_dir, "").sub("/", "") coverage_lines = v.each_with_index.map do |covered, lineNr| if !covered.nil? [(lineNr + 1).to_s, covered] else nil end end.compact lines_covered = v.compact.length == 0 ? 0 : ((coverage_lines.count { |x| x[1] > 0 }.to_f / v.compact.length) * 100).round Hash[ [['filename', file_dir], ['total', lines_covered], ['coverage', Hash[coverage_lines]]] ] end total = simplecov_result.source_files.covered_percent.round Hash[[['total', total], ['fileReports', file_reports]]] end private def self.logger Codacy::Configuration.logger end end end
Version data entries
8 entries across 8 versions & 1 rubygems