danger-jacoco-instacart 0.1.9 → 0.1.12
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 +4 -4
- data/.yardoc/checksums +15 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +1 -0
- data/lib/jacoco/gem_version.rb +1 -1
- data/lib/jacoco/plugin.rb +70 -22
- data/spec/fixtures/output_a.xml +1 -1
- data/spec/fixtures/output_b.xml +0 -2
- data/spec/fixtures/output_c.xml +73 -0
- data/spec/fixtures/output_d.xml +35 -0
- data/spec/fixtures/output_e.xml +34 -0
- data/spec/fixtures/output_f.xml +33 -0
- data/spec/jacoco_spec.rb +195 -3
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1abc0461e9b260a95c412ad877e45259ee557f26b9ed4de55eaa982cc84a0dad
|
4
|
+
data.tar.gz: be45bc45af39819be0735aa3d9a5456118a317c597890da3145fb00cbabe6b2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f3260792e92abff7de9d85f6cf67c6c93233b6b492937049167cf37a72f3e2dfc90dba09f8ba14da85e9a5991c8602c54439275c7c3b601026cbcd00b0afe3
|
7
|
+
data.tar.gz: 84bbc4e0f01417de4dac8a1d2b2da1c07e65e69769828154fa1bda935ffc8639145e79132ea0bc12734ac01e3c72fbac78717dc18f55a232b5d9d63e8019a409
|
data/.yardoc/checksums
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_jacoco.rb 38229d934b3315bb2a5a4eec18eb65f3c54d304f
|
2
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb fcee9a884aa0707169357197da0ee6d6298be6fa
|
3
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb f1cb8c9c21dde323e5f7dd51b3f4387094361fcc
|
4
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/sax_parser.rb 370e2799f8dbdf7d642c820214e6ea84c30c9cb0
|
5
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/counter.rb 368f4a9811617b7a174ddf837a8fac49a4bc32a6
|
6
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/report.rb 7cf45ee71ff347a130320f6190ddb25525c7095d
|
7
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/class.rb 89c78fdda05e07a709ddfb1d5ae9fb2472eaa504
|
8
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/method.rb 37076c751eb37683c0071c154319b85a987a2708
|
9
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/group.rb 6a8ccb32c793842af49c5c2d0d015bf01b0ec537
|
10
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/sourcefile.rb 19ffc9500370f50807af91a6f177c42d5879aabd
|
11
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/session_info.rb 5c908a9f96bd054d202edfeb30f29dcb4b42a1c9
|
12
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/line.rb ff5d6fc5bf0bf808c46d4bafce0f3fc53c8fdd73
|
13
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/package.rb b865b8eca41323dfc832babc08179fb94b5dfb0f
|
14
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/dom_parser.rb d08e0ca8531dd04bc9261a57fc03852b23883965
|
15
|
+
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_plugin.rb f5f82beb7e326604e1003f368e15da243263c0cf
|
data/.yardoc/complete
ADDED
File without changes
|
Binary file
|
Binary file
|
data/.yardoc/proxy_types
ADDED
Binary file
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ jacoco.minimum_class_coverage_map = { # optional (default is empty)
|
|
23
23
|
'com/package/more/specific/ClassName' => 15
|
24
24
|
}
|
25
25
|
jacoco.minimum_class_coverage_percentage = 75 # default 0
|
26
|
+
jacoco.only_check_new_files = true # default false
|
26
27
|
jacoco.files_extension = [".java"] # default [".kt", ".java"]
|
27
28
|
jacoco.report("path/to/jacoco.xml", "http://jacoco-html-reports/")
|
28
29
|
```
|
data/lib/jacoco/gem_version.rb
CHANGED
data/lib/jacoco/plugin.rb
CHANGED
@@ -20,17 +20,34 @@ module Danger
|
|
20
20
|
# @tags jacoco, coverage, java, android, kotlin
|
21
21
|
#
|
22
22
|
class DangerJacoco < Plugin # rubocop:disable Metrics/ClassLength
|
23
|
-
attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
|
24
|
-
:
|
23
|
+
attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
|
24
|
+
:minimum_composable_class_coverage_percentage, :only_check_new_files, :files_extension,
|
25
|
+
:minimum_package_coverage_map, :minimum_class_coverage_map, :fail_no_coverage_data_found,
|
26
|
+
:title, :class_column_title, :subtitle_success, :subtitle_failure
|
25
27
|
|
26
28
|
# Initialize the plugin with configured parameters or defaults
|
27
29
|
def setup
|
30
|
+
setup_minimum_coverages
|
31
|
+
setup_texts
|
32
|
+
@only_check_new_files = false unless only_check_new_files
|
33
|
+
@files_extension = ['.kt', '.java'] unless files_extension
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initialize the plugin with configured optional texts
|
37
|
+
def setup_texts
|
38
|
+
@title = 'JaCoCo' unless title
|
39
|
+
@class_column_title = 'Class' unless class_column_title
|
40
|
+
@subtitle_success = 'All classes meet coverage requirement. Well done! :white_check_mark:' unless subtitle_success
|
41
|
+
@subtitle_failure = 'There are classes that do not meet coverage requirement :warning:' unless subtitle_failure
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initialize the plugin with configured coverage minimum parameters or defaults
|
45
|
+
def setup_minimum_coverages
|
28
46
|
@minimum_project_coverage_percentage = 0 unless minimum_project_coverage_percentage
|
29
47
|
@minimum_class_coverage_percentage = 0 unless minimum_class_coverage_percentage
|
48
|
+
@minimum_composable_class_coverage_percentage = 0 unless minimum_composable_class_coverage_percentage
|
30
49
|
@minimum_package_coverage_map = {} unless minimum_package_coverage_map
|
31
50
|
@minimum_class_coverage_map = {} unless minimum_class_coverage_map
|
32
|
-
@files_extension = ['.kt', '.java'] unless files_extension
|
33
|
-
@title = 'JaCoCo' unless title
|
34
51
|
end
|
35
52
|
|
36
53
|
# Parses the xml output of jacoco to Ruby model classes
|
@@ -59,36 +76,48 @@ module Danger
|
|
59
76
|
# Java => blah/blah/java/slashed_package/Source.java
|
60
77
|
# Kotlin => blah/blah/kotlin/slashed_package/Source.kt
|
61
78
|
#
|
79
|
+
# rubocop:disable Style/AbcSize
|
62
80
|
def report(path, report_url = '', delimiter = %r{/java/|/kotlin/}, fail_no_coverage_data_found: true)
|
63
81
|
@fail_no_coverage_data_found = fail_no_coverage_data_found
|
64
82
|
|
65
83
|
setup
|
66
|
-
|
84
|
+
class_to_file_path_hash = classes(delimiter)
|
85
|
+
classnames = class_to_file_path_hash.keys
|
67
86
|
|
68
|
-
parser = Jacoco::SAXParser.new(
|
87
|
+
parser = Jacoco::SAXParser.new(classnames)
|
69
88
|
Nokogiri::XML::SAX::Parser.new(parser).parse(File.open(path))
|
70
89
|
|
71
90
|
total_covered = total_coverage(path)
|
72
91
|
|
73
|
-
|
74
|
-
report_markdown
|
92
|
+
header = "### #{title} Code Coverage #{total_covered[:covered]}% #{total_covered[:status]}\n"
|
93
|
+
report_markdown = header
|
94
|
+
report_markdown += "| #{class_column_title} | Covered | Required | Status |\n"
|
75
95
|
report_markdown += "|:---|:---:|:---:|:---:|\n"
|
76
|
-
class_coverage_above_minimum = markdown_class(parser, report_markdown, report_url)
|
96
|
+
class_coverage_above_minimum = markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
|
97
|
+
subtitle = class_coverage_above_minimum ? subtitle_success : subtitle_failure
|
98
|
+
report_markdown.insert(header.length, "#### #{subtitle}\n")
|
77
99
|
markdown(report_markdown)
|
78
100
|
|
79
101
|
report_fails(class_coverage_above_minimum, total_covered)
|
80
102
|
end
|
103
|
+
# rubocop:enable Style/AbcSize
|
81
104
|
|
82
|
-
# Select modified and added files in this PR
|
105
|
+
# Select either only added files or modified and added files in this PR,
|
106
|
+
# depending on "only_check_new_files" attribute
|
83
107
|
def classes(delimiter)
|
84
108
|
git = @dangerfile.git
|
85
|
-
affected_files = git.
|
109
|
+
affected_files = only_check_new_files ? git.added_files : git.added_files + git.modified_files
|
110
|
+
class_to_file_path_hash = {}
|
86
111
|
affected_files.select { |file| files_extension.reduce(false) { |state, el| state || file.end_with?(el) } }
|
87
|
-
.
|
112
|
+
.each do |file| # "src/java/com/example/CachedRepository.java"
|
113
|
+
classname = file.split('.').first.split(delimiter)[1] # "com/example/CachedRepository"
|
114
|
+
class_to_file_path_hash[classname] = file
|
115
|
+
end
|
116
|
+
class_to_file_path_hash
|
88
117
|
end
|
89
118
|
|
90
119
|
# It returns a specific class code coverage and an emoji status as well
|
91
|
-
def report_class(jacoco_class)
|
120
|
+
def report_class(jacoco_class, file_path)
|
92
121
|
report_result = {
|
93
122
|
covered: 'No coverage data found : -',
|
94
123
|
status: ':black_joker:',
|
@@ -98,7 +127,7 @@ module Danger
|
|
98
127
|
counter = coverage_counter(jacoco_class)
|
99
128
|
unless counter.nil?
|
100
129
|
coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
|
101
|
-
required_coverage = required_class_coverage(jacoco_class)
|
130
|
+
required_coverage = required_class_coverage(jacoco_class, file_path)
|
102
131
|
status = coverage_status(coverage, required_coverage)
|
103
132
|
|
104
133
|
report_result = {
|
@@ -112,13 +141,19 @@ module Danger
|
|
112
141
|
end
|
113
142
|
|
114
143
|
# Determines the required coverage for the class
|
115
|
-
|
144
|
+
# rubocop:disable Metrics/AbcSize
|
145
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
146
|
+
def required_class_coverage(jacoco_class, file_path)
|
116
147
|
key = minimum_class_coverage_map.keys.detect { |k| jacoco_class.name.match(k) } || jacoco_class.name
|
117
148
|
required_coverage = minimum_class_coverage_map[key]
|
149
|
+
includes_composables = File.read(file_path).include? '@Composable' if File.exist?(file_path)
|
150
|
+
required_coverage = minimum_composable_class_coverage_percentage if required_coverage.nil? && includes_composables
|
118
151
|
required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
|
119
152
|
required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
|
120
153
|
required_coverage
|
121
154
|
end
|
155
|
+
# rubocop:enable Metrics/AbcSize
|
156
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
122
157
|
|
123
158
|
# it returns the most suitable coverage by package name to class or nil
|
124
159
|
def package_coverage(class_name)
|
@@ -138,7 +173,8 @@ module Danger
|
|
138
173
|
def coverage_status(coverage, minimum_percentage)
|
139
174
|
if coverage < (minimum_percentage / 2) then ':skull:'
|
140
175
|
elsif coverage < minimum_percentage then ':warning:'
|
141
|
-
else
|
176
|
+
else
|
177
|
+
':white_check_mark:'
|
142
178
|
end
|
143
179
|
end
|
144
180
|
|
@@ -162,10 +198,8 @@ module Danger
|
|
162
198
|
private
|
163
199
|
|
164
200
|
def coverage_counter(jacoco_class)
|
165
|
-
|
166
|
-
|
167
|
-
line_counter = counters.detect { |e| e.type.eql? 'LINE' }
|
168
|
-
counter = branch_counter.nil? ? line_counter : branch_counter
|
201
|
+
all_class_counters = jacoco_class.counters
|
202
|
+
counter = class_counter(all_class_counters)
|
169
203
|
|
170
204
|
if counter.nil?
|
171
205
|
no_coverage_data_found_message = "No coverage data found for #{jacoco_class.name}"
|
@@ -178,6 +212,19 @@ module Danger
|
|
178
212
|
counter
|
179
213
|
end
|
180
214
|
|
215
|
+
def class_counter(all_class_counters)
|
216
|
+
instruction_counter = all_class_counters.detect { |e| e.type.eql? 'INSTRUCTION' }
|
217
|
+
branch_counter = all_class_counters.detect { |e| e.type.eql? 'BRANCH' }
|
218
|
+
line_counter = all_class_counters.detect { |e| e.type.eql? 'LINE' }
|
219
|
+
if !instruction_counter.nil?
|
220
|
+
instruction_counter
|
221
|
+
elsif !branch_counter.nil?
|
222
|
+
branch_counter
|
223
|
+
else
|
224
|
+
line_counter
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
181
228
|
# rubocop:disable Style/SignalException
|
182
229
|
def report_fails(class_coverage_above_minimum, total_covered)
|
183
230
|
if total_covered[:covered] < minimum_project_coverage_percentage
|
@@ -192,10 +239,11 @@ module Danger
|
|
192
239
|
end
|
193
240
|
# rubocop:enable Style/SignalException
|
194
241
|
|
195
|
-
def markdown_class(parser, report_markdown, report_url)
|
242
|
+
def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
|
196
243
|
class_coverage_above_minimum = true
|
197
244
|
parser.classes.each do |jacoco_class| # Check metrics for each classes
|
198
|
-
|
245
|
+
file_path = class_to_file_path_hash[jacoco_class.name]
|
246
|
+
rp = report_class(jacoco_class, file_path)
|
199
247
|
rl = report_link(jacoco_class.name, report_url)
|
200
248
|
ln = "| #{rl} | #{rp[:covered]}% | #{rp[:required_coverage_percentage]}% | #{rp[:status]} |\n"
|
201
249
|
report_markdown << ln
|
data/spec/fixtures/output_a.xml
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
11
11
|
<counter type="METHOD" missed="0" covered="1"/>
|
12
12
|
</method>
|
13
|
-
<counter type="INSTRUCTION" missed="
|
13
|
+
<counter type="INSTRUCTION" missed="46" covered="46"/>
|
14
14
|
<counter type="LINE" missed="0" covered="14"/>
|
15
15
|
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
16
16
|
<counter type="METHOD" missed="0" covered="7"/>
|
data/spec/fixtures/output_b.xml
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
10
|
<counter type="METHOD" missed="0" covered="1"/>
|
11
11
|
</method>
|
12
|
-
<counter type="INSTRUCTION" missed="0" covered="46"/>
|
13
12
|
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
13
|
<counter type="METHOD" missed="0" covered="7"/>
|
15
14
|
<counter type="CLASS" missed="0" covered="1"/>
|
@@ -17,7 +16,6 @@
|
|
17
16
|
<sourcefile name="CachedRepository.java">
|
18
17
|
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
19
18
|
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
20
|
-
<counter type="INSTRUCTION" missed="2" covered="98"/>
|
21
19
|
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
22
20
|
<counter type="METHOD" missed="2" covered="11"/>
|
23
21
|
<counter type="CLASS" missed="2" covered="4"/>
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="LINE" missed="0" covered="5"/>
|
10
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
11
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
12
|
+
</method>
|
13
|
+
<counter type="INSTRUCTION" missed="46" covered="46"/>
|
14
|
+
<counter type="LINE" missed="0" covered="14"/>
|
15
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
16
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
17
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
18
|
+
<counter type="BRANCH" missed="2" covered="2" />
|
19
|
+
</class>
|
20
|
+
<sourcefile name="CachedRepository.java">
|
21
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
22
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
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"/>
|
28
|
+
</sourcefile>
|
29
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
30
|
+
<counter type="BRANCH" missed="4" covered="4"/>
|
31
|
+
<counter type="LINE" missed="24" covered="68"/>
|
32
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
33
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
34
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
35
|
+
</package>
|
36
|
+
<package name="io/sample">
|
37
|
+
<class name="io/sample/UseCase">
|
38
|
+
<method name="<init>" desc="()V" line="17">
|
39
|
+
<counter type="INSTRUCTION" missed="3" covered="8"/>
|
40
|
+
<counter type="LINE" missed="0" covered="7"/>
|
41
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
42
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
43
|
+
</method>
|
44
|
+
<counter type="INSTRUCTION" missed="18" covered="36"/>
|
45
|
+
<counter type="LINE" missed="0" covered="12"/>
|
46
|
+
<counter type="COMPLEXITY" missed="5" covered="8"/>
|
47
|
+
<counter type="METHOD" missed="0" covered="9"/>
|
48
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
49
|
+
<counter type="BRANCH" missed="1" covered="2" />
|
50
|
+
</class>
|
51
|
+
<sourcefile name="UseCase.java">
|
52
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
53
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
54
|
+
<counter type="INSTRUCTION" missed="2" covered="48"/>
|
55
|
+
<counter type="LINE" missed="2" covered="9"/>
|
56
|
+
<counter type="COMPLEXITY" missed="2" covered="8"/>
|
57
|
+
<counter type="METHOD" missed="2" covered="7"/>
|
58
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
59
|
+
</sourcefile>
|
60
|
+
<counter type="INSTRUCTION" missed="101" covered="201"/>
|
61
|
+
<counter type="BRANCH" missed="4" covered="4"/>
|
62
|
+
<counter type="LINE" missed="54" covered="78"/>
|
63
|
+
<counter type="COMPLEXITY" missed="21" covered="29"/>
|
64
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
65
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
66
|
+
</package>
|
67
|
+
<counter type="INSTRUCTION" missed="39399" covered="49321"/>
|
68
|
+
<counter type="BRANCH" missed="3463" covered="4039"/>
|
69
|
+
<counter type="LINE" missed="9611" covered="9974"/>
|
70
|
+
<counter type="COMPLEXITY" missed="5517" covered="6444"/>
|
71
|
+
<counter type="METHOD" missed="3382" covered="4120"/>
|
72
|
+
<counter type="CLASS" missed="491" covered="570"/>
|
73
|
+
</report>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="INSTRUCTION" missed="46" covered="118"/>
|
13
|
+
<counter type="LINE" missed="1" covered="14"/>
|
14
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
15
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
16
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
17
|
+
<counter type="BRANCH" missed="2" covered="3" />
|
18
|
+
</class>
|
19
|
+
<sourcefile name="CachedRepository.java">
|
20
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
21
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
22
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
23
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
24
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
25
|
+
</sourcefile>
|
26
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
27
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
28
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
29
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
30
|
+
</package>
|
31
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
32
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
33
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
34
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
35
|
+
</report>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="LINE" missed="1" covered="14"/>
|
13
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
15
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
16
|
+
<counter type="BRANCH" missed="4" covered="3" />
|
17
|
+
</class>
|
18
|
+
<sourcefile name="CachedRepository.java">
|
19
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
20
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
21
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
22
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
23
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
24
|
+
</sourcefile>
|
25
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
26
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
27
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
28
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
29
|
+
</package>
|
30
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
31
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
32
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
33
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
34
|
+
</report>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="LINE" missed="1" covered="14"/>
|
13
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
15
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
16
|
+
</class>
|
17
|
+
<sourcefile name="CachedRepository.java">
|
18
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
19
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
20
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
21
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
22
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
23
|
+
</sourcefile>
|
24
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
25
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
26
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
27
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
28
|
+
</package>
|
29
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
30
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
31
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
32
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
33
|
+
</report>
|
data/spec/jacoco_spec.rb
CHANGED
@@ -21,7 +21,7 @@ module Danger
|
|
21
21
|
@my_plugin = @dangerfile.jacoco
|
22
22
|
|
23
23
|
modified_files = ['src/java/com/example/CachedRepository.java']
|
24
|
-
added_files = ['src/java/
|
24
|
+
added_files = ['src/java/io/sample/UseCase.java']
|
25
25
|
|
26
26
|
allow(@dangerfile.git).to receive(:modified_files).and_return(modified_files)
|
27
27
|
allow(@dangerfile.git).to receive(:added_files).and_return(added_files)
|
@@ -38,7 +38,7 @@ module Danger
|
|
38
38
|
expect(@dangerfile.status_report[:errors]).to eq(['Total coverage of 32.9%. Improve this to at least 50%',
|
39
39
|
'Class coverage is below minimum. Improve to at least 0%'])
|
40
40
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 32.9% :warning:')
|
41
|
-
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered |
|
41
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
42
42
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
|
43
43
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
|
44
44
|
end
|
@@ -108,7 +108,7 @@ module Danger
|
|
108
108
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
|
109
109
|
end
|
110
110
|
|
111
|
-
it 'test with overlapped package coverage and
|
111
|
+
it 'test with overlapped package coverage and lower class coverage' do
|
112
112
|
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
113
113
|
|
114
114
|
@my_plugin.minimum_project_coverage_percentage = 50
|
@@ -123,6 +123,48 @@ module Danger
|
|
123
123
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 80% | :warning: |')
|
124
124
|
end
|
125
125
|
|
126
|
+
it 'checks modified files when "only_check_new_files" attribute is false' do
|
127
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
|
128
|
+
|
129
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
130
|
+
@my_plugin.only_check_new_files = false
|
131
|
+
|
132
|
+
@my_plugin.report path_a
|
133
|
+
|
134
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
|
135
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
136
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
|
137
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 0% | :white_check_mark: |')
|
138
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 0% | :white_check_mark: |')
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'defaults "only_check_new_files" attribute to false' do
|
142
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
|
143
|
+
|
144
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
145
|
+
|
146
|
+
@my_plugin.report path_a
|
147
|
+
|
148
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 0% | :white_check_mark: |')
|
149
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 0% | :white_check_mark: |')
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'does _not_ check modified files when "only_check_new_files" attribute is true' do
|
153
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
|
154
|
+
|
155
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
156
|
+
@my_plugin.minimum_class_coverage_percentage = 70
|
157
|
+
@my_plugin.only_check_new_files = true
|
158
|
+
|
159
|
+
@my_plugin.report path_a
|
160
|
+
|
161
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
|
162
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
163
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
|
164
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 70% | :warning: |')
|
165
|
+
expect(@dangerfile.status_report[:markdowns][0].message).not_to include('com/example/CachedRepository')
|
166
|
+
end
|
167
|
+
|
126
168
|
it 'adds a link to report' do
|
127
169
|
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
128
170
|
|
@@ -169,6 +211,156 @@ module Danger
|
|
169
211
|
|
170
212
|
expect { @my_plugin.report path_a, fail_no_coverage_data_found: false }.to_not raise_error(RuntimeError)
|
171
213
|
end
|
214
|
+
|
215
|
+
it 'prints default success subtitle' do
|
216
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
217
|
+
|
218
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
219
|
+
@my_plugin.minimum_class_coverage_percentage = 40
|
220
|
+
|
221
|
+
@my_plugin.report path_a
|
222
|
+
|
223
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
224
|
+
expected += "#### All classes meet coverage requirement. Well done! :white_check_mark:\n"
|
225
|
+
expected += "| Class | Covered | Required | Status |\n"
|
226
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
227
|
+
expected += "| `com/example/CachedRepository` | 50% | 40% | :white_check_mark: |\n"
|
228
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'prints default failure subtitle' do
|
232
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
233
|
+
|
234
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
235
|
+
@my_plugin.minimum_class_coverage_percentage = 60
|
236
|
+
|
237
|
+
@my_plugin.report path_a
|
238
|
+
|
239
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
240
|
+
expected += "#### There are classes that do not meet coverage requirement :warning:\n"
|
241
|
+
expected += "| Class | Covered | Required | Status |\n"
|
242
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
243
|
+
expected += "| `com/example/CachedRepository` | 50% | 60% | :warning: |\n"
|
244
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'prints custom success subtitle' do
|
248
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
249
|
+
|
250
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
251
|
+
@my_plugin.minimum_class_coverage_percentage = 40
|
252
|
+
@my_plugin.subtitle_success = 'You rock! 🔥'
|
253
|
+
|
254
|
+
@my_plugin.report path_a
|
255
|
+
|
256
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
257
|
+
expected += "#### You rock! 🔥\n"
|
258
|
+
expected += "| Class | Covered | Required | Status |\n"
|
259
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
260
|
+
expected += "| `com/example/CachedRepository` | 50% | 40% | :white_check_mark: |\n"
|
261
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'prints custom failure subtitle' do
|
265
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
266
|
+
|
267
|
+
@my_plugin.minimum_project_coverage_percentage = 30
|
268
|
+
@my_plugin.minimum_class_coverage_percentage = 60
|
269
|
+
@my_plugin.subtitle_failure = 'Too bad :('
|
270
|
+
|
271
|
+
@my_plugin.report path_a
|
272
|
+
|
273
|
+
expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
|
274
|
+
expected += "#### Too bad :(\n"
|
275
|
+
expected += "| Class | Covered | Required | Status |\n"
|
276
|
+
expected += "|:---|:---:|:---:|:---:|\n"
|
277
|
+
expected += "| `com/example/CachedRepository` | 50% | 60% | :warning: |\n"
|
278
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include(expected)
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'prints default class column title' do
|
282
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
283
|
+
|
284
|
+
@my_plugin.report path_a
|
285
|
+
|
286
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
|
287
|
+
end
|
288
|
+
|
289
|
+
it 'prints custom class column title' do
|
290
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
291
|
+
|
292
|
+
@my_plugin.class_column_title = 'New files'
|
293
|
+
|
294
|
+
@my_plugin.report path_a
|
295
|
+
|
296
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| New files | Covered | Required | Status |')
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'instruction coverage takes over all the rest coverages for classes' do
|
300
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_d.xml"
|
301
|
+
|
302
|
+
@my_plugin.minimum_class_coverage_percentage = 50
|
303
|
+
|
304
|
+
@my_plugin.report path_a
|
305
|
+
|
306
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 71% | 50% | :white_check_mark: |')
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'branch coverage takes over line coverage for classes, when instruction coverage is not available' do
|
310
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_e.xml"
|
311
|
+
|
312
|
+
@my_plugin.minimum_class_coverage_percentage = 50
|
313
|
+
|
314
|
+
@my_plugin.report path_a
|
315
|
+
|
316
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 42% | 50% | :warning: |')
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'line coverage takes over for classes, when both instruction coverage and branch coverage are not available' do
|
320
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_f.xml"
|
321
|
+
|
322
|
+
@my_plugin.minimum_class_coverage_percentage = 50
|
323
|
+
|
324
|
+
@my_plugin.report path_a
|
325
|
+
|
326
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 93% | 50% | :white_check_mark: |')
|
327
|
+
end
|
328
|
+
|
329
|
+
describe 'with CachedRepository containing @Composable annotation' do
|
330
|
+
before do
|
331
|
+
allow(File).to receive(:exist?).with('src/java/com/example/CachedRepository.java').and_return(true)
|
332
|
+
allow(File).to receive(:read).with('src/java/com/example/CachedRepository.java').and_return('package com.kevin.mia.mikaela class Vika { @Composable fun someUiWidget() {} }')
|
333
|
+
end
|
334
|
+
|
335
|
+
it 'applies minimum_composable_class_coverage_percentage' do
|
336
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
337
|
+
|
338
|
+
@my_plugin.minimum_class_coverage_percentage = 55
|
339
|
+
@my_plugin.minimum_composable_class_coverage_percentage = 45
|
340
|
+
|
341
|
+
@my_plugin.report path_a
|
342
|
+
|
343
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 45% | :white_check_mark: |')
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
describe 'with CachedRepository _not_ containing @Composable annotation' do
|
348
|
+
before do
|
349
|
+
allow(File).to receive(:exist?).with('src/java/com/example/CachedRepository.java').and_return(true)
|
350
|
+
allow(File).to receive(:read).with('src/java/com/example/CachedRepository.java').and_return('package com.kevin.mia.mikaela class Vika { fun main() {} }')
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'does not apply minimum_composable_class_coverage_percentage' do
|
354
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
355
|
+
|
356
|
+
@my_plugin.minimum_class_coverage_percentage = 55
|
357
|
+
@my_plugin.minimum_composable_class_coverage_percentage = 45
|
358
|
+
|
359
|
+
@my_plugin.report path_a
|
360
|
+
|
361
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 55% | :warning: |')
|
362
|
+
end
|
363
|
+
end
|
172
364
|
end
|
173
365
|
end
|
174
366
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-jacoco-instacart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Malinskiy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: danger-plugin-api
|
@@ -179,6 +179,11 @@ files:
|
|
179
179
|
- ".github/workflows/release.yaml"
|
180
180
|
- ".gitignore"
|
181
181
|
- ".rubocop.yml"
|
182
|
+
- ".yardoc/checksums"
|
183
|
+
- ".yardoc/complete"
|
184
|
+
- ".yardoc/object_types"
|
185
|
+
- ".yardoc/objects/root.dat"
|
186
|
+
- ".yardoc/proxy_types"
|
182
187
|
- Gemfile
|
183
188
|
- Guardfile
|
184
189
|
- LICENSE.txt
|
@@ -202,6 +207,10 @@ files:
|
|
202
207
|
- lib/jacoco/sax_parser.rb
|
203
208
|
- spec/fixtures/output_a.xml
|
204
209
|
- spec/fixtures/output_b.xml
|
210
|
+
- spec/fixtures/output_c.xml
|
211
|
+
- spec/fixtures/output_d.xml
|
212
|
+
- spec/fixtures/output_e.xml
|
213
|
+
- spec/fixtures/output_f.xml
|
205
214
|
- spec/jacoco_spec.rb
|
206
215
|
- spec/spec_helper.rb
|
207
216
|
homepage: https://github.com/alexanderbezverhni/danger-jacoco
|
@@ -230,5 +239,9 @@ summary: A longer description of danger-jacoco.
|
|
230
239
|
test_files:
|
231
240
|
- spec/fixtures/output_a.xml
|
232
241
|
- spec/fixtures/output_b.xml
|
242
|
+
- spec/fixtures/output_c.xml
|
243
|
+
- spec/fixtures/output_d.xml
|
244
|
+
- spec/fixtures/output_e.xml
|
245
|
+
- spec/fixtures/output_f.xml
|
233
246
|
- spec/jacoco_spec.rb
|
234
247
|
- spec/spec_helper.rb
|