lib/jacoco/plugin.rb
def total_coverage(report_path)
      jacoco_report = Nokogiri::XML(File.open(report_path))

      report = jacoco_report.xpath('report/counter').select { |item| item['type'] == 'INSTRUCTION' }
      missed_instructions = report.first['missed'].to_f
      covered_instructions = report.first['covered'].to_f
      total_instructions = missed_instructions + covered_instructions
      covered_percentage = (covered_instructions * 100 / total_instructions).round(2)
      coverage_status = coverage_status(covered_percentage, minimum_project_coverage_percentage)

      {
        covered: covered_percentage,
        status: coverage_status
      }
    end
def total_coverage(report_path)
      jacoco_report = Nokogiri::XML(File.open(report_path))

      report = jacoco_report.xpath('report/counter').select { |item| item['type'] == 'INSTRUCTION' }
      missed_instructions = report.first['missed'].to_f
      covered_instructions = report.first['covered'].to_f
      total_instructions = missed_instructions + covered_instructions
      covered_percentage = (covered_instructions * 100 / total_instructions).round(2)
      coverage_status = coverage_status(covered_percentage, minimum_project_coverage_percentage)

      {
        covered: covered_percentage,
        status: coverage_status
      }
    end
def total_coverage ( report_path ) jacoco_report = Nokogiri :: XML ( File . open ( report_path ) ) report = jacoco_report . xpath ( 'report/counter' ) . select { | item | item [ 'type' ] == 'INSTRUCTION' } missed_instructions = report . first [ 'missed' ] . to_f covered_instructions = report . first [ 'covered' ] . to_f total_instructions = missed_instructions + covered_instructions covered_percentage = ( covered_instructions * 100 / total_instructions ) . round ( 2 ) coverage_status = coverage_status ( covered_percentage , minimum_project_coverage_percentage ) { covered : covered_percentage , status : coverage_status } end
It returns total of project code coverage and an emoji status as well
It returns total of project code coverage and an emoji status as well