danger-jacoco-instacart 0.1.14 → 0.1.15

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: 2796b44c6c3c0252797c88e6836096d3f528524f2a3719111607df5375e00afa
4
- data.tar.gz: bd5f313356ca48dc58e35a35c425b4b158686f924264fcacd1a48d54cb9a2108
3
+ metadata.gz: 0dd4a48316de722878c9a9a93259094c27b8ac841391399eb11bfec956379fee
4
+ data.tar.gz: 8d0f4f5cdaa727efd0d6edcc119790661bc9c63b1e28a16d3fce4adc7f6239ba
5
5
  SHA512:
6
- metadata.gz: b9a81a4673b390c90b0e58626cad1a0b922a1158f6425f7e0999b03ca7c41c1d94b7b6bbe4ffc13eb0a4fb79dc2dff801f61d78b7945845b091bb79a3a71d8df
7
- data.tar.gz: 283344a767f8500e3fda05291cb12c5a18c525ec8e0fd191ab8cae1f63d79c07c38f5140cb8334b5cb0449116977f653b7b00cc0d33fd0625f903c0f9253336a
6
+ metadata.gz: b8eb83937c2a0cf5b1fad92fa98c160d9cc481793b3eeb51f1b8a71239ecc8cd0bcd4b5f6d32fc093c5b01a4cfba9e4bd119b66e13ebd58d797ca9486e3a3e72
7
+ data.tar.gz: 14567a96d7cb741c17a5dbaff165ee9bc6dd09b3e293319c644081938a20c7f6bcfe363cb34d9370f0a1b637fb8d89788f8d00632b2c164e628c510821330b3b
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jacoco
4
- VERSION = '0.1.14'
4
+ VERSION = '0.1.15'
5
5
  end
data/lib/jacoco/plugin.rb CHANGED
@@ -31,7 +31,7 @@ module Danger
31
31
  setup_texts
32
32
  @files_to_check = [] unless files_to_check
33
33
  @files_extension = ['.kt', '.java'] unless files_extension
34
- @file_to_create_on_failure = 'danger_jacoco_failure_status_file.txt' unless file_to_create_on_failure
34
+ @file_to_create_on_failure = 'danger_jacoco_failure_status_file.json' unless file_to_create_on_failure
35
35
  end
36
36
 
37
37
  # Initialize the plugin with configured optional texts
@@ -99,7 +99,7 @@ module Danger
99
99
  report_markdown.insert(header.length, "#### #{subtitle}\n")
100
100
  markdown(report_markdown)
101
101
 
102
- report_fails(class_coverage_above_minimum, total_covered)
102
+ report_fails(parser, report_url, class_coverage_above_minimum, total_covered)
103
103
  end
104
104
  # rubocop:enable Style/AbcSize
105
105
 
@@ -223,13 +223,13 @@ module Danger
223
223
  end
224
224
 
225
225
  # rubocop:disable Style/SignalException
226
- def report_fails(class_coverage_above_minimum, total_covered)
226
+ def report_fails(parser, report_url, class_coverage_above_minimum, total_covered)
227
227
  if total_covered[:covered] < minimum_project_coverage_percentage
228
228
  # fail danger if total coverage is smaller than minimum_project_coverage_percentage
229
229
  covered = total_covered[:covered]
230
230
  fail("Total coverage of #{covered}%. Improve this to at least #{minimum_project_coverage_percentage}%")
231
231
  # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that this line is unreachable since priorly called "fail" raises an error, but in fact "fail" is caught and handled)
232
- create_status_file_on_failure if class_coverage_above_minimum
232
+ create_status_file_on_failure(parser, report_url) if class_coverage_above_minimum
233
233
  # rubocop:enable Lint/UnreachableCode
234
234
  end
235
235
 
@@ -237,13 +237,20 @@ module Danger
237
237
 
238
238
  fail("Class coverage is below minimum. Improve to at least #{minimum_class_coverage_percentage}%")
239
239
  # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that this line is unreachable since priorly called "fail" raises an error, but in fact "fail" is caught and handled)
240
- create_status_file_on_failure
240
+ create_status_file_on_failure(parser, report_url)
241
241
  # rubocop:enable Lint/UnreachableCode
242
242
  end
243
243
  # rubocop:enable Style/SignalException
244
244
 
245
- def create_status_file_on_failure
246
- File.open(file_to_create_on_failure, 'w') {}
245
+ def create_status_file_on_failure(parser, report_url)
246
+ data = []
247
+ parser.classes.each do |jacoco_class|
248
+ data.push({ 'name' => jacoco_class.name, 'path' => report_filepath(jacoco_class.name, report_url) })
249
+ end
250
+
251
+ File.open(file_to_create_on_failure, 'w') do |f|
252
+ f.write({ 'failures' => data }.to_json)
253
+ end
247
254
  end
248
255
 
249
256
  def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
@@ -265,8 +272,15 @@ module Danger
265
272
  if report_url.empty?
266
273
  "`#{class_name}`"
267
274
  else
268
- report_filepath = "#{class_name.gsub(%r{/(?=[^/]*/.)}, '.')}.html"
269
- "[`#{class_name}`](#{report_url + report_filepath})"
275
+ "[`#{class_name}`](#{report_url + report_filepath(class_name, report_url)})"
276
+ end
277
+ end
278
+
279
+ def report_filepath(class_name, report_url)
280
+ if report_url.empty?
281
+ class_name
282
+ else
283
+ "#{class_name.gsub(%r{/(?=[^/]*/.)}, '.')}.html"
270
284
  end
271
285
  end
272
286
  end
data/spec/jacoco_spec.rb CHANGED
@@ -58,7 +58,7 @@ module Danger
58
58
  @my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
59
59
  @my_plugin.minimum_class_coverage_percentage = 60
60
60
 
61
- expect(File).to receive(:open).with('danger_jacoco_failure_status_file.txt', 'w')
61
+ expect(File).to receive(:open).with('danger_jacoco_failure_status_file.json', 'w')
62
62
  @my_plugin.report path_a
63
63
  end
64
64
 
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.14
4
+ version: 0.1.15
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-09-09 00:00:00.000000000 Z
12
+ date: 2023-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: danger-plugin-api