Sha256: 674e88941f28c43e27059755ddbaad4bf691784b0bc386b39de7f94f89ca672f
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
module Codacy module Parser def self.parse_file(simplecov_result) project_dir = Dir.pwd 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? && covered > 0 [(lineNr + 1).to_s, covered] else nil end end.compact lines_covered = v.compact.length == 0 ? 0 : ((coverage_lines.length.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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
codacy-coverage-0.2.1 | lib/codacy/parser.rb |
codacy-coverage-0.2.0 | lib/codacy/parser.rb |
codacy-coverage-0.1.0 | lib/codacy/parser.rb |
codacy-coverage-0.0.1 | lib/codacy/parser.rb |