danger-jacoco 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: bbe04fa92db358efe7b876a9cc4a96ba345fed7f
4
- data.tar.gz: 4ee1125c139adce7f13e98ff8233a1ddae339640
3
+ metadata.gz: 41f06316cc4d1805a8a86dbd4957500b059b1a96
4
+ data.tar.gz: f03bd63af127ad7b93e4e284602451e6307e6f34
5
5
  SHA512:
6
- metadata.gz: 3b781beccdd7e277ed4a6296864ea3e1fb56315aa0bb636ae4e0002b758cd0dc5f55702e0c0380f4007501f1a87ff405e7c460cb349fd02eacba7c3d52f49acf
7
- data.tar.gz: c3708a9d043202c10748711683cfefddab20808eec536c2790a3f56ec463f47b306224fa6303f8c5d54174fc8e31ca38083629c5116ea2293a5fca66f71f3e63
6
+ metadata.gz: 472aaa07a8b9592fd940054882f52d03207cdc45a9d4703bda6fe087fd03f0da54a5409f0a2f8f1437cdb9b58b675a06ffbc97c8cb325a69c47275c51e7644e4
7
+ data.tar.gz: da9c29738c04da81dde72eda8320209339dbbb4b2f9a6f91cf4a61ae9f283439182fd64c8b2aa4a5e7a05716300d523c5e619815bcc7b7a10ba2d1d47ebaf8d6
data/README.md CHANGED
@@ -17,7 +17,7 @@ Add
17
17
  jacoco.minimum_project_coverage_percentage = 50 # default 0
18
18
  jacoco.minimum_class_coverage_percentage = 75 # default 0
19
19
  jacoco.files_extension = [".java"] # default [".kt", ".java"]
20
- jacoco.report "path/to/jacoco.xml"
20
+ jacoco.report("path/to/jacoco.xml", "http://jacoco-html-reports/")
21
21
  ```
22
22
 
23
23
  to your `Dangerfile`
@@ -1,3 +1,3 @@
1
1
  module Jacoco
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
@@ -30,6 +30,7 @@ module Danger
30
30
  # This is a fast report based on SAX parser
31
31
  #
32
32
  # @path path to the xml output of jacoco
33
+ # @report_url URL where html report hosted
33
34
  # @delimiter git.modified_files returns full paths to the
34
35
  # changed files. We need to get the class from this path to check the
35
36
  # Jacoco report,
@@ -43,7 +44,7 @@ module Danger
43
44
  # Java => blah/blah/java/slashed_package/Source.java
44
45
  # Kotlin => blah/blah/kotlin/slashed_package/Source.kt
45
46
  #
46
- def report(path, delimiter = %r{\/java\/|\/kotlin\/})
47
+ def report(path, report_url = '', delimiter = %r{\/java\/|\/kotlin\/})
47
48
  setup
48
49
  classes = classes(delimiter)
49
50
 
@@ -54,8 +55,8 @@ module Danger
54
55
 
55
56
  report_markdown = "### JaCoCO Code Coverage #{total_covered[:covered]}% #{total_covered[:status]}\n"
56
57
  report_markdown << "| Class | Covered | Meta | Status |\n"
57
- report_markdown << "|:---:|:---:|:---:|:---:|\n"
58
- class_coverage_above_minimum = markdown_class(parser, report_markdown)
58
+ report_markdown << "|:---|:---:|:---:|:---:|\n"
59
+ class_coverage_above_minimum = markdown_class(parser, report_markdown, report_url)
59
60
  markdown(report_markdown)
60
61
 
61
62
  report_fails(class_coverage_above_minimum, total_covered)
@@ -135,11 +136,12 @@ module Danger
135
136
  end
136
137
  # rubocop:enable Style/SignalException
137
138
 
138
- def markdown_class(parser, report_markdown)
139
+ def markdown_class(parser, report_markdown, report_url)
139
140
  class_coverage_above_minimum = true
140
141
  parser.classes.each do |jacoco_class| # Check metrics for each classes
141
142
  rp = report_class(jacoco_class)
142
- ln = "| `#{jacoco_class.name}` | #{rp[:covered]}% | #{rp[:required_coverage_percentage]}% | #{rp[:status]} |\n"
143
+ rl = report_link(jacoco_class.name, report_url)
144
+ ln = "| #{rl} | #{rp[:covered]}% | #{rp[:required_coverage_percentage]}% | #{rp[:status]} |\n"
143
145
  report_markdown << ln
144
146
 
145
147
  class_coverage_above_minimum &&= rp[:covered] >= rp[:required_coverage_percentage]
@@ -147,5 +149,15 @@ module Danger
147
149
 
148
150
  class_coverage_above_minimum
149
151
  end
152
+
153
+ def report_link(class_name, report_url)
154
+ if report_url.empty?
155
+ "`#{class_name}`"
156
+ else
157
+ report_filepath = class_name.gsub(/\/(?=[^\/]*\/.)/, '.') + ".html"
158
+ "[`#{class_name}`](#{report_url + report_filepath})"
159
+ end
160
+ end
161
+
150
162
  end
151
163
  end
@@ -36,11 +36,23 @@ module Danger
36
36
  "Class coverage is below minimum. Improve to at least 0%"])
37
37
  expect(@dangerfile.status_report[:markdowns][0].message).to include("### JaCoCO Code Coverage 32.9% :warning:")
38
38
  expect(@dangerfile.status_report[:markdowns][0].message).to include("| Class | Covered | Meta | Status |")
39
- expect(@dangerfile.status_report[:markdowns][0].message).to include("|:---:|:---:|:---:|:---:|")
39
+ expect(@dangerfile.status_report[:markdowns][0].message).to include("|:---|:---:|:---:|:---:|")
40
40
  expect(@dangerfile.status_report[:markdowns][0].message).to include("| `com/example/CachedRepository` | 50% | 100% | :warning: |")
41
41
 
42
42
  end
43
43
 
44
+ it 'adds a link to report' do
45
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
46
+
47
+ @my_plugin.minimum_class_coverage_percentage = 80
48
+ @my_plugin.minimum_project_coverage_percentage = 50
49
+
50
+ @my_plugin.report(path_a, 'http://test.com/')
51
+
52
+ expect(@dangerfile.status_report[:markdowns][0].message).to include("| [`com/example/CachedRepository`](http://test.com/com.example/CachedRepository.html) | 50% | 80% | :warning: |")
53
+
54
+ end
55
+
44
56
  end
45
57
  end
46
58
  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.3
4
+ version: 0.1.4
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-10-26 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api