danger-jacoco 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 371b0dde165ac428614147067f7e6afb770a5612
4
- data.tar.gz: 8ca1e6cdcee1c395c4627c6a41254ea80b64a43c
3
+ metadata.gz: bbe04fa92db358efe7b876a9cc4a96ba345fed7f
4
+ data.tar.gz: 4ee1125c139adce7f13e98ff8233a1ddae339640
5
5
  SHA512:
6
- metadata.gz: d216754af4136b642921a1bae373a437e97cf0f99326be3260d8b77bfa02aa94735eab6077f0cc1721d57e2fea6e917f7c6effec83c4cfe94d1f04f9650ec411
7
- data.tar.gz: 02f1ffc71d5eac688733f5165f6cf9152df4542d4f29d2f3ad20b3ddb635b964f9bf05124c211998fe75073cd625fb01506dde6600d36280510e3003246946dd
6
+ metadata.gz: 3b781beccdd7e277ed4a6296864ea3e1fb56315aa0bb636ae4e0002b758cd0dc5f55702e0c0380f4007501f1a87ff405e7c460cb349fd02eacba7c3d52f49acf
7
+ data.tar.gz: c3708a9d043202c10748711683cfefddab20808eec536c2790a3f56ec463f47b306224fa6303f8c5d54174fc8e31ca38083629c5116ea2293a5fca66f71f3e63
@@ -1,3 +1,3 @@
1
1
  module Jacoco
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
@@ -9,10 +9,12 @@ module Danger
9
9
  attr_accessor :minimum_project_coverage_percentage
10
10
  attr_accessor :minimum_class_coverage_percentage
11
11
  attr_accessor :files_extension
12
+ attr_accessor :minimum_class_coverage_map
12
13
 
13
14
  def setup
14
15
  @minimum_project_coverage_percentage = 0 unless minimum_project_coverage_percentage
15
16
  @minimum_class_coverage_percentage = 0 unless minimum_class_coverage_percentage
17
+ @minimum_class_coverage_map = {} unless minimum_class_coverage_map
16
18
  @files_extension = ['.kt', '.java'] unless files_extension
17
19
  end
18
20
 
@@ -71,11 +73,14 @@ module Danger
71
73
  def report_class(jacoco_class)
72
74
  counter = coverage_counter(jacoco_class)
73
75
  coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
74
- status = coverage_status(coverage, minimum_class_coverage_percentage)
76
+ required_coverage = minimum_class_coverage_map[jacoco_class.name]
77
+ required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
78
+ status = coverage_status(coverage, required_coverage)
75
79
 
76
80
  {
77
81
  covered: coverage,
78
- status: status
82
+ status: status,
83
+ required_coverage_percentage: required_coverage
79
84
  }
80
85
  end
81
86
 
@@ -128,15 +133,16 @@ module Danger
128
133
 
129
134
  fail("Class coverage is below minimum. Improve to at least #{minimum_class_coverage_percentage}%")
130
135
  end
136
+ # rubocop:enable Style/SignalException
131
137
 
132
138
  def markdown_class(parser, report_markdown)
133
139
  class_coverage_above_minimum = true
134
140
  parser.classes.each do |jacoco_class| # Check metrics for each classes
135
141
  rp = report_class(jacoco_class)
136
- ln = "| `#{jacoco_class.name}` | #{rp[:covered]}% | #{minimum_class_coverage_percentage}% | #{rp[:status]} |\n"
142
+ ln = "| `#{jacoco_class.name}` | #{rp[:covered]}% | #{rp[:required_coverage_percentage]}% | #{rp[:status]} |\n"
137
143
  report_markdown << ln
138
144
 
139
- class_coverage_above_minimum &&= rp[:covered] >= minimum_class_coverage_percentage
145
+ class_coverage_above_minimum &&= rp[:covered] >= rp[:required_coverage_percentage]
140
146
  end
141
147
 
142
148
  class_coverage_above_minimum
@@ -3,7 +3,7 @@
3
3
  <report name="test_report">
4
4
  <sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
5
5
  <package name="com/example">
6
- <class name="com/example/MemoryCache">
6
+ <class name="com/example/CachedRepository">
7
7
  <method name="&lt;init&gt;" desc="()V" line="17">
8
8
  <counter type="INSTRUCTION" missed="0" covered="11"/>
9
9
  <counter type="LINE" missed="0" covered="5"/>
@@ -12,18 +12,19 @@
12
12
  </method>
13
13
  <counter type="INSTRUCTION" missed="0" covered="46"/>
14
14
  <counter type="LINE" missed="0" covered="14"/>
15
- <counter type="COMPLEXITY" missed="0" covered="7"/>
15
+ <counter type="COMPLEXITY" missed="5" covered="7"/>
16
16
  <counter type="METHOD" missed="0" covered="7"/>
17
17
  <counter type="CLASS" missed="0" covered="1"/>
18
+ <counter type="BRANCH" missed="2" covered="2" />
18
19
  </class>
19
20
  <sourcefile name="CachedRepository.java">
20
21
  <line nr="16" mi="0" ci="2" mb="0" cb="0"/>
21
22
  <line nr="17" mi="0" ci="3" mb="0" cb="0"/>
22
- <counter type="INSTRUCTION" missed="0" covered="98"/>
23
- <counter type="LINE" missed="0" covered="19"/>
24
- <counter type="COMPLEXITY" missed="0" covered="11"/>
25
- <counter type="METHOD" missed="0" covered="11"/>
26
- <counter type="CLASS" missed="0" covered="4"/>
23
+ <counter type="INSTRUCTION" missed="2" covered="98"/>
24
+ <counter type="LINE" missed="2" covered="19"/>
25
+ <counter type="COMPLEXITY" missed="2" covered="11"/>
26
+ <counter type="METHOD" missed="2" covered="11"/>
27
+ <counter type="CLASS" missed="2" covered="4"/>
27
28
  </sourcefile>
28
29
  <counter type="INSTRUCTION" missed="80" covered="324"/>
29
30
  <counter type="BRANCH" missed="4" covered="4"/>
@@ -1,13 +1,46 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ require File.expand_path("../spec_helper", __FILE__)
2
2
 
3
- module Jacoco
4
- describe Jacoco::DOMParser do
5
- path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
3
+ module Danger
4
+
5
+ describe Danger::DangerJacoco do
6
+ it "should be a plugin" do
7
+ expect(Danger::DangerJacoco.new(nil)).to be_a Danger::Plugin
8
+ end
9
+
10
+ #
11
+ # You should test your custom attributes and methods here
12
+ #
13
+ describe "with Dangerfile" do
14
+ before do
15
+ @dangerfile = testing_dangerfile
16
+ @my_plugin = @dangerfile.jacoco
17
+
18
+ modified_files = ['src/java/com/example/CachedRepository.java']
19
+ added_files = ['src/java/Blah.java']
20
+
21
+ allow(@dangerfile.git).to receive(:modified_files).and_return(modified_files)
22
+ allow(@dangerfile.git).to receive(:added_files).and_return(added_files)
6
23
 
7
- describe 'read xml' do
8
- it 'reads report' do
9
- Jacoco::DOMParser.read_path(path_a)
10
24
  end
25
+
26
+
27
+ it :report do
28
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
29
+
30
+ @my_plugin.minimum_project_coverage_percentage = 50
31
+ @my_plugin.minimum_class_coverage_map = { "com/example/CachedRepository" => 100}
32
+
33
+ @my_plugin.report path_a
34
+
35
+ expect(@dangerfile.status_report[:errors]).to eq(["Total coverage of 32.9%. Improve this to at least 50%",
36
+ "Class coverage is below minimum. Improve to at least 0%"])
37
+ expect(@dangerfile.status_report[:markdowns][0].message).to include("### JaCoCO Code Coverage 32.9% :warning:")
38
+ expect(@dangerfile.status_report[:markdowns][0].message).to include("| Class | Covered | Meta | Status |")
39
+ expect(@dangerfile.status_report[:markdowns][0].message).to include("|:---:|:---:|:---:|:---:|")
40
+ expect(@dangerfile.status_report[:markdowns][0].message).to include("| `com/example/CachedRepository` | 50% | 100% | :warning: |")
41
+
42
+ end
43
+
11
44
  end
12
45
  end
13
46
  end
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Malinskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api