danger-jacoco-instacart 0.1.13.SNAPSHOT.1 → 0.1.13

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: f29acbe4cffe4ddeae3ab9f829a1dc5310da2f837aa8afd313d3cd16ddd63ad6
4
- data.tar.gz: f74387bb9bb4307342e9baff55c011d52d2e06281bf86decfbd858f6962854f3
3
+ metadata.gz: 04b74ccc5974fdd122bb8909a71b541891e760d99f7cfd120c06d71c133c2b32
4
+ data.tar.gz: 9f8e75aa5cf7611307255edb1ae2119e81f5c7010700d324d1b7041cd7d5d275
5
5
  SHA512:
6
- metadata.gz: 591ee3b4094f83a2f69e152b4d5f956a1402f3ee84c932287389aa017065743c3e88017c1979b043044e6961991be05da0ca6ad74ad26f13c726ef14ea24eae3
7
- data.tar.gz: 130a3e11af52b5598603edeed78e57a6039528e7bf38f7cebdd9b8427cbf7d83f3654c572a17a89e1b5329d343a59e7f1cb22a9e7df18c04e097bd4f9cf368b3
6
+ metadata.gz: da2bc98c6c2693be43e96012f0ac3b2000911fca7610fba47387046f908797eb49a4b2f04d505af4ddd359cae44703725c1216bf9716bb0cf62c58b20636dca5
7
+ data.tar.gz: 9f768d669d1eb720bf898ab9fbdfd6deb8fd68994a67ae490938eee2fd4c693dcfb0a06314b466fef6c9109424f037738171e77113546579986a1ca6dfce4266
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 8f31621c2d22f454fcaacb2640694c9c6e7f1fb8
3
- /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb e0262efb6d2458fa4ad4e2138c1f8a10fb11a1de
2
+ /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb 1c81f68cb95296bfd592c1b57e0f2e6341f56b55
3
+ /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb e99030c6a408c1bc77962b844d74c324daecad40
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
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jacoco
4
- VERSION = '0.1.13.SNAPSHOT.1'
4
+ VERSION = '0.1.13'
5
5
  end
data/lib/jacoco/plugin.rb CHANGED
@@ -21,7 +21,7 @@ module Danger
21
21
  #
22
22
  class DangerJacoco < Plugin # rubocop:disable Metrics/ClassLength
23
23
  attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
24
- :minimum_composable_class_coverage_percentage, :files_to_check, :files_extension,
24
+ :minimum_composable_class_coverage_percentage, :only_check_new_files, :files_extension,
25
25
  :minimum_package_coverage_map, :minimum_class_coverage_map, :fail_no_coverage_data_found,
26
26
  :title, :class_column_title, :subtitle_success, :subtitle_failure, :file_to_create_on_failure
27
27
 
@@ -29,7 +29,7 @@ module Danger
29
29
  def setup
30
30
  setup_minimum_coverages
31
31
  setup_texts
32
- @files_to_check = [] unless files_to_check
32
+ @only_check_new_files = false unless only_check_new_files
33
33
  @files_extension = ['.kt', '.java'] unless files_extension
34
34
  @file_to_create_on_failure = 'danger_jacoco_failure_status_file.txt' unless file_to_create_on_failure
35
35
  end
@@ -103,9 +103,13 @@ module Danger
103
103
  end
104
104
  # rubocop:enable Style/AbcSize
105
105
 
106
+ # Select either only added files or modified and added files in this PR,
107
+ # depending on "only_check_new_files" attribute
106
108
  def classes(delimiter)
109
+ git = @dangerfile.git
110
+ affected_files = only_check_new_files ? git.added_files : git.added_files + git.modified_files
107
111
  class_to_file_path_hash = {}
108
- files_to_check.select { |file| files_extension.reduce(false) { |state, el| state || file.end_with?(el) } }
112
+ affected_files.select { |file| files_extension.reduce(false) { |state, el| state || file.end_with?(el) } }
109
113
  .each do |file| # "src/java/com/example/CachedRepository.java"
110
114
  classname = file.split('.').first.split(delimiter)[1] # "com/example/CachedRepository"
111
115
  class_to_file_path_hash[classname] = file
data/spec/jacoco_spec.rb CHANGED
@@ -20,13 +20,17 @@ module Danger
20
20
  @dangerfile = testing_dangerfile
21
21
  @my_plugin = @dangerfile.jacoco
22
22
 
23
+ modified_files = ['src/java/com/example/CachedRepository.java']
24
+ added_files = ['src/java/io/sample/UseCase.java']
25
+
26
+ allow(@dangerfile.git).to receive(:modified_files).and_return(modified_files)
27
+ allow(@dangerfile.git).to receive(:added_files).and_return(added_files)
23
28
  allow(File).to receive(:open).and_call_original
24
29
  end
25
30
 
26
31
  it :report do
27
32
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
28
33
 
29
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
30
34
  @my_plugin.minimum_project_coverage_percentage = 50
31
35
  @my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 100 }
32
36
 
@@ -43,7 +47,6 @@ module Danger
43
47
  it 'creates supplied status file upon failure' do
44
48
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
45
49
 
46
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
47
50
  @my_plugin.minimum_project_coverage_percentage = 100
48
51
  @my_plugin.minimum_class_coverage_percentage = 60
49
52
  @my_plugin.file_to_create_on_failure = 'kmm.txt'
@@ -55,7 +58,6 @@ module Danger
55
58
  it 'creates default status file upon failure' do
56
59
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
57
60
 
58
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
59
61
  @my_plugin.minimum_class_coverage_percentage = 60
60
62
 
61
63
  expect(File).to receive(:open).with('danger_jacoco_failure_status_file.txt', 'w')
@@ -65,7 +67,6 @@ module Danger
65
67
  it 'does _not_ create status file upon success' do
66
68
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
67
69
 
68
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
69
70
  @my_plugin.minimum_class_coverage_percentage = 40
70
71
  @my_plugin.file_to_create_on_failure = 'kmm.txt'
71
72
 
@@ -76,7 +77,6 @@ module Danger
76
77
  it 'test regex class coverage' do
77
78
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
78
79
 
79
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
80
80
  @my_plugin.minimum_project_coverage_percentage = 50
81
81
  @my_plugin.minimum_class_coverage_map = { '.*Repository' => 60 }
82
82
 
@@ -88,7 +88,6 @@ module Danger
88
88
  it 'test with package coverage' do
89
89
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
90
90
 
91
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
92
91
  @my_plugin.minimum_project_coverage_percentage = 50
93
92
  @my_plugin.minimum_package_coverage_map = { 'com/example/' => 70 }
94
93
 
@@ -100,7 +99,6 @@ module Danger
100
99
  it 'test with bigger overlapped package coverage' do
101
100
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
102
101
 
103
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
104
102
  @my_plugin.minimum_project_coverage_percentage = 50
105
103
  @my_plugin.minimum_package_coverage_map = {
106
104
  'com/example/' => 70,
@@ -115,7 +113,6 @@ module Danger
115
113
  it 'test with lower overlapped package coverage' do
116
114
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
117
115
 
118
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
119
116
  @my_plugin.minimum_project_coverage_percentage = 50
120
117
  @my_plugin.minimum_package_coverage_map = {
121
118
  'com/example/' => 77,
@@ -130,7 +127,6 @@ module Danger
130
127
  it 'test with overlapped package coverage and bigger class coverage' do
131
128
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
132
129
 
133
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
134
130
  @my_plugin.minimum_project_coverage_percentage = 50
135
131
  @my_plugin.minimum_package_coverage_map = {
136
132
  'com/example/' => 77,
@@ -146,7 +142,6 @@ module Danger
146
142
  it 'test with overlapped package coverage and lower class coverage' do
147
143
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
148
144
 
149
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
150
145
  @my_plugin.minimum_project_coverage_percentage = 50
151
146
  @my_plugin.minimum_package_coverage_map = {
152
147
  'com/example/' => 90,
@@ -159,10 +154,24 @@ module Danger
159
154
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 80% | :warning: |')
160
155
  end
161
156
 
157
+ it 'checks modified files when "only_check_new_files" attribute is false' do
158
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
159
+
160
+ @my_plugin.minimum_project_coverage_percentage = 50
161
+ @my_plugin.only_check_new_files = false
162
+
163
+ @my_plugin.report path_a
164
+
165
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
166
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
167
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
168
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 0% | :white_check_mark: |')
169
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 0% | :white_check_mark: |')
170
+ end
171
+
162
172
  it 'defaults "only_check_new_files" attribute to false' do
163
173
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
164
174
 
165
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
166
175
  @my_plugin.minimum_project_coverage_percentage = 50
167
176
 
168
177
  @my_plugin.report path_a
@@ -171,10 +180,25 @@ module Danger
171
180
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 0% | :white_check_mark: |')
172
181
  end
173
182
 
183
+ it 'does _not_ check modified files when "only_check_new_files" attribute is true' do
184
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_c.xml"
185
+
186
+ @my_plugin.minimum_project_coverage_percentage = 50
187
+ @my_plugin.minimum_class_coverage_percentage = 70
188
+ @my_plugin.only_check_new_files = true
189
+
190
+ @my_plugin.report path_a
191
+
192
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
193
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
194
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('|:---|:---:|:---:|:---:|')
195
+ expect(@dangerfile.status_report[:markdowns][0].message).to include('| `io/sample/UseCase` | 66% | 70% | :warning: |')
196
+ expect(@dangerfile.status_report[:markdowns][0].message).not_to include('com/example/CachedRepository')
197
+ end
198
+
174
199
  it 'adds a link to report' do
175
200
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
176
201
 
177
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
178
202
  @my_plugin.minimum_class_coverage_percentage = 80
179
203
  @my_plugin.minimum_project_coverage_percentage = 50
180
204
 
@@ -186,7 +210,6 @@ module Danger
186
210
  it 'When option "fail_no_coverage_data_found" is set to optionally fail, it doesn\'t fail the execution' do
187
211
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
188
212
 
189
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
190
213
  @my_plugin.minimum_class_coverage_percentage = 80
191
214
  @my_plugin.minimum_project_coverage_percentage = 50
192
215
 
@@ -196,7 +219,6 @@ module Danger
196
219
  it 'When option "fail_no_coverage_data_found" is not set, the execution fails on empty data' do
197
220
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_b.xml"
198
221
 
199
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
200
222
  @my_plugin.minimum_class_coverage_percentage = 80
201
223
  @my_plugin.minimum_project_coverage_percentage = 50
202
224
 
@@ -206,7 +228,6 @@ module Danger
206
228
  it 'When option "fail_no_coverage_data_found" is set to optionally fail, the execution fails on empty data' do
207
229
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_b.xml"
208
230
 
209
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
210
231
  @my_plugin.minimum_class_coverage_percentage = 80
211
232
  @my_plugin.minimum_project_coverage_percentage = 50
212
233
 
@@ -216,7 +237,6 @@ module Danger
216
237
  it 'When option "fail_no_coverage_data_found" is set to optionally warn (not fail), the execution doesn\'t fail on empty data' do
217
238
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_b.xml"
218
239
 
219
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
220
240
  @my_plugin.minimum_class_coverage_percentage = 80
221
241
  @my_plugin.minimum_project_coverage_percentage = 50
222
242
 
@@ -226,7 +246,6 @@ module Danger
226
246
  it 'prints default success subtitle' do
227
247
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
228
248
 
229
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
230
249
  @my_plugin.minimum_project_coverage_percentage = 30
231
250
  @my_plugin.minimum_class_coverage_percentage = 40
232
251
 
@@ -243,7 +262,6 @@ module Danger
243
262
  it 'prints default failure subtitle' do
244
263
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
245
264
 
246
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
247
265
  @my_plugin.minimum_project_coverage_percentage = 30
248
266
  @my_plugin.minimum_class_coverage_percentage = 60
249
267
 
@@ -260,7 +278,6 @@ module Danger
260
278
  it 'prints custom success subtitle' do
261
279
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
262
280
 
263
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
264
281
  @my_plugin.minimum_project_coverage_percentage = 30
265
282
  @my_plugin.minimum_class_coverage_percentage = 40
266
283
  @my_plugin.subtitle_success = 'You rock! 🔥'
@@ -278,7 +295,6 @@ module Danger
278
295
  it 'prints custom failure subtitle' do
279
296
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
280
297
 
281
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
282
298
  @my_plugin.minimum_project_coverage_percentage = 30
283
299
  @my_plugin.minimum_class_coverage_percentage = 60
284
300
  @my_plugin.subtitle_failure = 'Too bad :('
@@ -296,8 +312,6 @@ module Danger
296
312
  it 'prints default class column title' do
297
313
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
298
314
 
299
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
300
-
301
315
  @my_plugin.report path_a
302
316
 
303
317
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
@@ -306,7 +320,6 @@ module Danger
306
320
  it 'prints custom class column title' do
307
321
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
308
322
 
309
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
310
323
  @my_plugin.class_column_title = 'New files'
311
324
 
312
325
  @my_plugin.report path_a
@@ -317,7 +330,6 @@ module Danger
317
330
  it 'instruction coverage takes over all the rest coverages for classes' do
318
331
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_d.xml"
319
332
 
320
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
321
333
  @my_plugin.minimum_class_coverage_percentage = 50
322
334
 
323
335
  @my_plugin.report path_a
@@ -328,7 +340,6 @@ module Danger
328
340
  it 'branch coverage takes over line coverage for classes, when instruction coverage is not available' do
329
341
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_e.xml"
330
342
 
331
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
332
343
  @my_plugin.minimum_class_coverage_percentage = 50
333
344
 
334
345
  @my_plugin.report path_a
@@ -339,7 +350,6 @@ module Danger
339
350
  it 'line coverage takes over for classes, when both instruction coverage and branch coverage are not available' do
340
351
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_f.xml"
341
352
 
342
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
343
353
  @my_plugin.minimum_class_coverage_percentage = 50
344
354
 
345
355
  @my_plugin.report path_a
@@ -356,7 +366,6 @@ module Danger
356
366
  it 'applies minimum_composable_class_coverage_percentage' do
357
367
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
358
368
 
359
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
360
369
  @my_plugin.minimum_class_coverage_percentage = 55
361
370
  @my_plugin.minimum_composable_class_coverage_percentage = 45
362
371
 
@@ -375,7 +384,6 @@ module Danger
375
384
  it 'does not apply minimum_composable_class_coverage_percentage' do
376
385
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
377
386
 
378
- @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
379
387
  @my_plugin.minimum_class_coverage_percentage = 55
380
388
  @my_plugin.minimum_composable_class_coverage_percentage = 45
381
389
 
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.13.SNAPSHOT.1
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Malinskiy
@@ -228,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  version: '2.6'
229
229
  required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  requirements:
231
- - - ">"
231
+ - - ">="
232
232
  - !ruby/object:Gem::Version
233
- version: 1.3.1
233
+ version: '0'
234
234
  requirements: []
235
235
  rubygems_version: 3.1.2
236
236
  signing_key: