lib/jacoco/plugin.rb in danger-jacoco-0.1.7 vs lib/jacoco/plugin.rb in danger-jacoco-0.1.8
- old
+ new
@@ -96,22 +96,29 @@
}
counter = coverage_counter(jacoco_class)
unless counter.nil?
coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
- required_coverage = minimum_class_coverage_map[jacoco_class.name]
- required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
- required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
+ required_coverage = required_class_coverage(jacoco_class)
status = coverage_status(coverage, required_coverage)
report_result = {
covered: coverage,
status: status,
required_coverage_percentage: required_coverage
}
end
report_result
+ end
+
+ # Determines the required coverage for the class
+ def required_class_coverage(jacoco_class)
+ key = minimum_class_coverage_map.keys.detect { |k| jacoco_class.name.match(k) } || jacoco_class.name
+ required_coverage = minimum_class_coverage_map[key]
+ required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
+ required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
+ required_coverage
end
# it returns the most suitable coverage by package name to class or nil
def package_coverage(class_name)
path = class_name