danger-jacoco 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4d5975aa9e605034d57f94ae6c1e83b5b9ba5f9b21be614a3266c5b8d70a36d
4
- data.tar.gz: 98ee2072a867384ae8d732cfef8dcda6b201a8da7706e2361481fa5add96bda4
3
+ metadata.gz: e27bdd91acf2d25a2fa8f0eb6e0a07e5375f6864d831d8ca3883437db5d95bd3
4
+ data.tar.gz: 4f5bfaf1bdecdf96e99044f0f63db762f52adbea608654b334f85e80588d3ae5
5
5
  SHA512:
6
- metadata.gz: 07e545a038ee4ea8c7aa81c77ef96a1b62756513f90cb9994d762b9f5605689e02eb2a4c2d56c7dfb15b1177e9b9e700f51f4dc44162a7663350031b28f84511
7
- data.tar.gz: 6138c222b2bcd09bf9c4e1744e256065bf9c1ac5e3d33c1b080252ccd0e7e50dfc2ab4dc92264bb8e32ab4428ab8887f5a7acbad715e9e8cca9cda210ac3b487
6
+ metadata.gz: 873ab75273b2c8cdefcd3fe3fb524e5fe2173debfa4cc96c44a0b8a5ec5c2de3d8e0a4c89107467d2abff3976d6e7244fd14fa7c5e0fed6bbad6b0c3e25e2b53
7
+ data.tar.gz: ac8dba5b3af75092aa7e483f5d0fdde9780df01aa5f38cbc3b6f9f71cc29f182d8bf50398425991900b976406c32f16923cda9acbfb6c7c49287ed7f6f06d32c
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jacoco
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.8'
5
5
  end
data/lib/jacoco/plugin.rb CHANGED
@@ -98,9 +98,7 @@ module Danger
98
98
  counter = coverage_counter(jacoco_class)
99
99
  unless counter.nil?
100
100
  coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
101
- required_coverage = minimum_class_coverage_map[jacoco_class.name]
102
- required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
103
- required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
101
+ required_coverage = required_class_coverage(jacoco_class)
104
102
  status = coverage_status(coverage, required_coverage)
105
103
 
106
104
  report_result = {
@@ -113,6 +111,15 @@ module Danger
113
111
  report_result
114
112
  end
115
113
 
114
+ # Determines the required coverage for the class
115
+ def required_class_coverage(jacoco_class)
116
+ key = minimum_class_coverage_map.keys.detect { |k| jacoco_class.name.match(k) } || jacoco_class.name
117
+ required_coverage = minimum_class_coverage_map[key]
118
+ required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
119
+ required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
120
+ required_coverage
121
+ end
122
+
116
123
  # it returns the most suitable coverage by package name to class or nil
117
124
  def package_coverage(class_name)
118
125
  path = class_name
data/spec/jacoco_spec.rb CHANGED
@@ -43,6 +43,17 @@ module Danger
43
43
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
44
44
  end
45
45
 
46
+ it 'test regex class coverage' do
47
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
48
+
49
+ @my_plugin.minimum_project_coverage_percentage = 50
50
+ @my_plugin.minimum_class_coverage_map = { '.*Repository' => 60 }
51
+
52
+ @my_plugin.report path_a
53
+
54
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 60% | :warning: |')
55
+ end
56
+
46
57
  it 'test with package coverage' do
47
58
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
48
59
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-jacoco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Malinskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api