danger-jacoco-instacart 0.1.11 → 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 +2 -2
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/lib/jacoco/gem_version.rb +1 -1
- data/lib/jacoco/plugin.rb +27 -12
- data/spec/jacoco_spec.rb +36 -0
- metadata +2 -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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_jacoco.rb 38229d934b3315bb2a5a4eec18eb65f3c54d304f
|
2
|
-
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb
|
3
|
-
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb
|
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
4
|
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/sax_parser.rb 370e2799f8dbdf7d642c820214e6ea84c30c9cb0
|
5
5
|
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/counter.rb 368f4a9811617b7a174ddf837a8fac49a4bc32a6
|
6
6
|
/Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/report.rb 7cf45ee71ff347a130320f6190ddb25525c7095d
|
data/.yardoc/object_types
CHANGED
Binary file
|
data/.yardoc/objects/root.dat
CHANGED
Binary file
|
data/lib/jacoco/gem_version.rb
CHANGED
data/lib/jacoco/plugin.rb
CHANGED
@@ -20,9 +20,10 @@ 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
|
-
:
|
25
|
-
:
|
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
|
26
27
|
|
27
28
|
# Initialize the plugin with configured parameters or defaults
|
28
29
|
def setup
|
@@ -44,6 +45,7 @@ module Danger
|
|
44
45
|
def setup_minimum_coverages
|
45
46
|
@minimum_project_coverage_percentage = 0 unless minimum_project_coverage_percentage
|
46
47
|
@minimum_class_coverage_percentage = 0 unless minimum_class_coverage_percentage
|
48
|
+
@minimum_composable_class_coverage_percentage = 0 unless minimum_composable_class_coverage_percentage
|
47
49
|
@minimum_package_coverage_map = {} unless minimum_package_coverage_map
|
48
50
|
@minimum_class_coverage_map = {} unless minimum_class_coverage_map
|
49
51
|
end
|
@@ -79,9 +81,10 @@ module Danger
|
|
79
81
|
@fail_no_coverage_data_found = fail_no_coverage_data_found
|
80
82
|
|
81
83
|
setup
|
82
|
-
|
84
|
+
class_to_file_path_hash = classes(delimiter)
|
85
|
+
classnames = class_to_file_path_hash.keys
|
83
86
|
|
84
|
-
parser = Jacoco::SAXParser.new(
|
87
|
+
parser = Jacoco::SAXParser.new(classnames)
|
85
88
|
Nokogiri::XML::SAX::Parser.new(parser).parse(File.open(path))
|
86
89
|
|
87
90
|
total_covered = total_coverage(path)
|
@@ -90,7 +93,7 @@ module Danger
|
|
90
93
|
report_markdown = header
|
91
94
|
report_markdown += "| #{class_column_title} | Covered | Required | Status |\n"
|
92
95
|
report_markdown += "|:---|:---:|:---:|:---:|\n"
|
93
|
-
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)
|
94
97
|
subtitle = class_coverage_above_minimum ? subtitle_success : subtitle_failure
|
95
98
|
report_markdown.insert(header.length, "#### #{subtitle}\n")
|
96
99
|
markdown(report_markdown)
|
@@ -104,12 +107,17 @@ module Danger
|
|
104
107
|
def classes(delimiter)
|
105
108
|
git = @dangerfile.git
|
106
109
|
affected_files = only_check_new_files ? git.added_files : git.added_files + git.modified_files
|
110
|
+
class_to_file_path_hash = {}
|
107
111
|
affected_files.select { |file| files_extension.reduce(false) { |state, el| state || file.end_with?(el) } }
|
108
|
-
.
|
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
|
109
117
|
end
|
110
118
|
|
111
119
|
# It returns a specific class code coverage and an emoji status as well
|
112
|
-
def report_class(jacoco_class)
|
120
|
+
def report_class(jacoco_class, file_path)
|
113
121
|
report_result = {
|
114
122
|
covered: 'No coverage data found : -',
|
115
123
|
status: ':black_joker:',
|
@@ -119,7 +127,7 @@ module Danger
|
|
119
127
|
counter = coverage_counter(jacoco_class)
|
120
128
|
unless counter.nil?
|
121
129
|
coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
|
122
|
-
required_coverage = required_class_coverage(jacoco_class)
|
130
|
+
required_coverage = required_class_coverage(jacoco_class, file_path)
|
123
131
|
status = coverage_status(coverage, required_coverage)
|
124
132
|
|
125
133
|
report_result = {
|
@@ -133,13 +141,19 @@ module Danger
|
|
133
141
|
end
|
134
142
|
|
135
143
|
# Determines the required coverage for the class
|
136
|
-
|
144
|
+
# rubocop:disable Metrics/AbcSize
|
145
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
146
|
+
def required_class_coverage(jacoco_class, file_path)
|
137
147
|
key = minimum_class_coverage_map.keys.detect { |k| jacoco_class.name.match(k) } || jacoco_class.name
|
138
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
|
139
151
|
required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
|
140
152
|
required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
|
141
153
|
required_coverage
|
142
154
|
end
|
155
|
+
# rubocop:enable Metrics/AbcSize
|
156
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
143
157
|
|
144
158
|
# it returns the most suitable coverage by package name to class or nil
|
145
159
|
def package_coverage(class_name)
|
@@ -225,10 +239,11 @@ module Danger
|
|
225
239
|
end
|
226
240
|
# rubocop:enable Style/SignalException
|
227
241
|
|
228
|
-
def markdown_class(parser, report_markdown, report_url)
|
242
|
+
def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
|
229
243
|
class_coverage_above_minimum = true
|
230
244
|
parser.classes.each do |jacoco_class| # Check metrics for each classes
|
231
|
-
|
245
|
+
file_path = class_to_file_path_hash[jacoco_class.name]
|
246
|
+
rp = report_class(jacoco_class, file_path)
|
232
247
|
rl = report_link(jacoco_class.name, report_url)
|
233
248
|
ln = "| #{rl} | #{rp[:covered]}% | #{rp[:required_coverage_percentage]}% | #{rp[:status]} |\n"
|
234
249
|
report_markdown << ln
|
data/spec/jacoco_spec.rb
CHANGED
@@ -325,6 +325,42 @@ module Danger
|
|
325
325
|
|
326
326
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 93% | 50% | :white_check_mark: |')
|
327
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
|
328
364
|
end
|
329
365
|
end
|
330
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
|