danger-shroud 0.0.7 → 1.0.0

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: 234c6bbce9b759a9a8b744c477e5b0f90ab40d742830635a6ff284f85b1b1015
4
- data.tar.gz: 21e54c40b94bdd7d4989516d5287279427888f07efc48475e6f754908f0b72c8
3
+ metadata.gz: 50b853e23a0b373fe8fd2d46815c09a2d4d56cd0ac66a41bacecffc7672446d3
4
+ data.tar.gz: af1b4ef7224ff201129b4dde31a3d08ab3a5d518e52e1721df8e1268d7d13c1a
5
5
  SHA512:
6
- metadata.gz: 4ad01b61dfe54625578c9e8b8b26f0520cffcee3d63e5f7275a1a45c332e503f4c2d0d254fb6619e35e9d20d51fc982d917e370be23668ed82f3293343b77fa5
7
- data.tar.gz: c5403ff85b292d6ad451ae73998e9fff69e76c462e260bf4dd8d918bc519fb88ff1fc38bde541421b25145eabbf70e96a04ceb4b1f26559b91f2f7fb53d30ef4
6
+ metadata.gz: 82769480c25715d5e29c5d07f70a5b5621f20bee17b19385245c730b6c1697827f820a86457817cf3f86df47a79d7e21fc5ac907bb074cbde434d4b648cc203a
7
+ data.tar.gz: 21a734fba89debfb859fdda47f3ccfafe62c50cdeda68c3ad8c94d4419fcbb2ba75e75a22a9caaa23fb168d48453cb3f7478a778fd87add19cf1889a5572aab7
data/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ Change Log
2
+ ==========
3
+
4
+ Version Next
5
+ ----------------------------
6
+
7
+
8
+ Version 1.0.0
9
+ ----------------------------
10
+
11
+ * Add 'coverageType' property and set default to ':line' instead of ':instruction'. (API Change)
12
+ * Add Named Parameters for all functions; users must now specify the name of each parameter being passed in. (Breaking Change)
13
+ * Remove 'report' function; users must now use 'reportKover' or 'reportJacoco' directly. (Breaking Change)
14
+
15
+ Version 0.0.7
16
+ ----------------------------
17
+
18
+ * Add separate variables for the 'failIfUnderProjectThreshold' and 'failIfUnderFileThreshold'.
19
+
20
+ Version 0.0.6
21
+ ----------------------------
22
+
23
+ * Target Ruby 2.7.2.
24
+ * Update publishing logic.
25
+
26
+ Version 0.0.5
27
+ ----------------------------
28
+
29
+ * Add support for Kover test reports.
30
+
31
+ Version 0.0.4
32
+ ----------------------------
33
+
34
+ * Migrate to Github Actions.
35
+
36
+ Version 0.0.3
37
+ ----------------------------
38
+
39
+ * Initial release.
data/Gemfile.lock CHANGED
@@ -1,16 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-shroud (0.0.7)
4
+ danger-shroud (1.0.0)
5
5
  danger-plugin-api (~> 1.0)
6
6
  nokogiri
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.4)
12
- public_suffix (>= 2.0.2, < 6.0)
11
+ addressable (2.8.7)
12
+ public_suffix (>= 2.0.2, < 7.0)
13
13
  ast (2.4.2)
14
+ base64 (0.2.0)
14
15
  claide (1.1.0)
15
16
  claide-plugins (0.9.2)
16
17
  cork
@@ -20,34 +21,36 @@ GEM
20
21
  colored2 (3.1.2)
21
22
  cork (0.3.0)
22
23
  colored2 (~> 3.1)
23
- danger (9.2.0)
24
+ danger (9.5.1)
25
+ base64 (~> 0.2)
24
26
  claide (~> 1.0)
25
27
  claide-plugins (>= 0.9.2)
26
28
  colored2 (~> 3.1)
27
29
  cork (~> 0.1)
28
30
  faraday (>= 0.9.0, < 3.0)
29
31
  faraday-http-cache (~> 2.0)
30
- git (~> 1.7)
32
+ git (~> 1.13)
31
33
  kramdown (~> 2.3)
32
34
  kramdown-parser-gfm (~> 1.0)
33
- no_proxy_fix
34
- octokit (~> 5.0)
35
+ octokit (>= 4.0)
36
+ pstore (~> 0.1)
35
37
  terminal-table (>= 1, < 4)
36
38
  danger-plugin-api (1.0.0)
37
39
  danger (> 2.0)
38
- diff-lcs (1.5.0)
39
- faraday (2.7.4)
40
+ diff-lcs (1.5.1)
41
+ faraday (2.8.1)
42
+ base64
40
43
  faraday-net_http (>= 2.0, < 3.1)
41
44
  ruby2_keywords (>= 0.0.4)
42
- faraday-http-cache (2.4.1)
45
+ faraday-http-cache (2.5.1)
43
46
  faraday (>= 0.8)
44
47
  faraday-net_http (3.0.2)
45
- ffi (1.15.5)
48
+ ffi (1.17.0)
46
49
  formatador (1.1.0)
47
- git (1.18.0)
50
+ git (1.19.1)
48
51
  addressable (~> 2.8)
49
52
  rchardet (~> 1.8)
50
- guard (2.18.0)
53
+ guard (2.19.0)
51
54
  formatador (>= 0.2.4)
52
55
  listen (>= 2.7, < 4.0)
53
56
  lumberjack (>= 1.0.12, < 2.0)
@@ -61,71 +64,73 @@ GEM
61
64
  guard (~> 2.1)
62
65
  guard-compat (~> 1.1)
63
66
  rspec (>= 2.99.0, < 4.0)
64
- json (2.6.3)
67
+ json (2.8.1)
65
68
  kramdown (2.4.0)
66
69
  rexml
67
70
  kramdown-parser-gfm (1.1.0)
68
71
  kramdown (~> 2.0)
72
+ language_server-protocol (3.17.0.3)
69
73
  listen (3.0.7)
70
74
  rb-fsevent (>= 0.9.3)
71
75
  rb-inotify (>= 0.9.7)
72
- lumberjack (1.2.8)
73
- method_source (1.0.0)
74
- mini_portile2 (2.8.1)
76
+ lumberjack (1.2.10)
77
+ method_source (1.1.0)
78
+ mini_portile2 (2.8.7)
75
79
  nap (1.1.0)
76
80
  nenv (0.3.0)
77
- no_proxy_fix (0.1.2)
78
- nokogiri (1.14.3)
79
- mini_portile2 (~> 2.8.0)
81
+ nokogiri (1.15.6)
82
+ mini_portile2 (~> 2.8.2)
80
83
  racc (~> 1.4)
81
84
  notiffany (0.1.3)
82
85
  nenv (~> 0.1)
83
86
  shellany (~> 0.0)
84
- octokit (5.6.1)
87
+ octokit (9.2.0)
85
88
  faraday (>= 1, < 3)
86
89
  sawyer (~> 0.9)
87
90
  open4 (1.3.4)
88
- parallel (1.22.1)
89
- parser (3.2.2.0)
91
+ parallel (1.26.3)
92
+ parser (3.3.6.0)
90
93
  ast (~> 2.4.1)
94
+ racc
91
95
  pry (0.14.2)
92
96
  coderay (~> 1.1)
93
97
  method_source (~> 1.0)
94
- public_suffix (5.0.1)
95
- racc (1.6.2)
98
+ pstore (0.1.3)
99
+ public_suffix (5.1.1)
100
+ racc (1.8.1)
96
101
  rainbow (3.1.1)
97
- rake (13.0.6)
102
+ rake (13.2.1)
98
103
  rb-fsevent (0.11.2)
99
- rb-inotify (0.10.1)
104
+ rb-inotify (0.11.1)
100
105
  ffi (~> 1.0)
101
106
  rchardet (1.8.0)
102
- regexp_parser (2.8.0)
103
- rexml (3.2.5)
104
- rspec (3.12.0)
105
- rspec-core (~> 3.12.0)
106
- rspec-expectations (~> 3.12.0)
107
- rspec-mocks (~> 3.12.0)
108
- rspec-core (3.12.1)
109
- rspec-support (~> 3.12.0)
110
- rspec-expectations (3.12.2)
107
+ regexp_parser (2.9.2)
108
+ rexml (3.3.9)
109
+ rspec (3.13.0)
110
+ rspec-core (~> 3.13.0)
111
+ rspec-expectations (~> 3.13.0)
112
+ rspec-mocks (~> 3.13.0)
113
+ rspec-core (3.13.2)
114
+ rspec-support (~> 3.13.0)
115
+ rspec-expectations (3.13.3)
111
116
  diff-lcs (>= 1.2.0, < 2.0)
112
- rspec-support (~> 3.12.0)
113
- rspec-mocks (3.12.5)
117
+ rspec-support (~> 3.13.0)
118
+ rspec-mocks (3.13.2)
114
119
  diff-lcs (>= 1.2.0, < 2.0)
115
- rspec-support (~> 3.12.0)
116
- rspec-support (3.12.0)
117
- rubocop (1.50.2)
120
+ rspec-support (~> 3.13.0)
121
+ rspec-support (3.13.1)
122
+ rubocop (1.68.0)
118
123
  json (~> 2.3)
124
+ language_server-protocol (>= 3.17.0)
119
125
  parallel (~> 1.10)
120
- parser (>= 3.2.0.0)
126
+ parser (>= 3.3.0.2)
121
127
  rainbow (>= 2.2.2, < 4.0)
122
- regexp_parser (>= 1.8, < 3.0)
123
- rexml (>= 3.2.5, < 4.0)
124
- rubocop-ast (>= 1.28.0, < 2.0)
128
+ regexp_parser (>= 2.4, < 3.0)
129
+ rubocop-ast (>= 1.32.2, < 2.0)
125
130
  ruby-progressbar (~> 1.7)
126
131
  unicode-display_width (>= 2.4.0, < 3.0)
127
- rubocop-ast (1.28.0)
128
- parser (>= 3.2.1.0)
132
+ rubocop-ast (1.36.1)
133
+ parser (>= 3.3.1.0)
129
134
  ruby-progressbar (1.13.0)
130
135
  ruby2_keywords (0.0.5)
131
136
  sawyer (0.9.2)
@@ -134,9 +139,9 @@ GEM
134
139
  shellany (0.0.1)
135
140
  terminal-table (3.0.2)
136
141
  unicode-display_width (>= 1.1.1, < 3)
137
- thor (1.2.1)
138
- unicode-display_width (2.4.2)
139
- yard (0.9.34)
142
+ thor (1.3.2)
143
+ unicode-display_width (2.6.0)
144
+ yard (0.9.37)
140
145
 
141
146
  PLATFORMS
142
147
  ruby
data/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  - [Parameters](#parameters-1)
9
9
  - [Examples](#examples-1)
10
10
  - [Development](#development)
11
+ - [Versioning](#versioning)
11
12
 
12
13
  # danger-shroud
13
14
 
@@ -31,14 +32,15 @@ Shroud depends on having a Kover coverage report generated for your project. For
31
32
 
32
33
  You can use the following parameters to control how shroud operates:
33
34
 
34
- Param | Type | Description | Example
35
- ---|---|---|---|
36
- moduleName | String | the display name of the project or module |`'Module Name '`
37
- file | String | file path to a Kover xml coverage report. | `'path/to/kover/report.xml'`
38
- totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90`
39
- modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90`
40
- failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
41
- failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
35
+ | Param | Type | Description | Example |
36
+ |-----------------------------|---------|---------------------------------------------------------------------------------------------|------------------------------|
37
+ | moduleName | String | the display name of the project or module. | `'Module Name '` |
38
+ | file | String | file path to a Kover xml coverage report. | `'path/to/kover/report.xml'` |
39
+ | totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90` |
40
+ | modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90` |
41
+ | failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
42
+ | failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
43
+ | coverageType | enum | the type of coverage to use (:branch, :class, :instruction, :line, and :method). | default `:line` |
42
44
 
43
45
  ### Examples
44
46
 
@@ -47,7 +49,7 @@ Running shroud with default values:
47
49
  ```ruby
48
50
  # Report coverage of modified files, fail if either total
49
51
  # project coverage or any modified file's coverage is under 90%
50
- shroud.reportKover 'Module Name', 'path/to/kover/report.xml'
52
+ shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml'
51
53
  ```
52
54
 
53
55
  Running shroud with custom coverage thresholds:
@@ -55,7 +57,7 @@ Running shroud with custom coverage thresholds:
55
57
  ```ruby
56
58
  # Report coverage of modified files, fail if total project coverage is under 80%,
57
59
  # or if any modified file's coverage is under 95%
58
- shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95
60
+ shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
59
61
  ```
60
62
 
61
63
  Warn on builds instead of fail:
@@ -63,7 +65,7 @@ Warn on builds instead of fail:
63
65
  ```ruby
64
66
  # Report coverage of modified files the same as the above example, except the
65
67
  # builds will only warn instead of fail if below project thresholds
66
- shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95, false, false
68
+ shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
67
69
  ```
68
70
 
69
71
  ## Usage Jacoco
@@ -72,14 +74,15 @@ shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95, false, fal
72
74
 
73
75
  You can use the following parameters to control how shroud operates:
74
76
 
75
- Param | Type | Description | Example
76
- ---|---|---|---|
77
- moduleName | String | the display name of the project or module |`'Module Name '`
78
- file | String | file path to a Kover xml coverage report. | `'path/to/jacoco/report.xml'`
79
- totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90`
80
- modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90`
81
- failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
82
- failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
77
+ | Param | Type | Description | Example |
78
+ |-----------------------------|---------|---------------------------------------------------------------------------------------------|-------------------------------|
79
+ | moduleName | String | the display name of the project or module. | `'Module Name '` |
80
+ | file | String | file path to a Jacoco xml coverage report. | `'path/to/jacoco/report.xml'` |
81
+ | totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90` |
82
+ | modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90` |
83
+ | failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
84
+ | failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
85
+ | coverageType | enum | the type of coverage to use (:branch, :class, :instruction, :line, and :method). | default `:line` |
83
86
 
84
87
  ### Examples
85
88
 
@@ -90,7 +93,7 @@ Running shroud with default values:
90
93
  ```ruby
91
94
  # Report coverage of modified files, fail if either total
92
95
  # project coverage or any modified file's coverage is under 90%
93
- shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml'
96
+ shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml'
94
97
  ```
95
98
 
96
99
  Running shroud with custom coverage thresholds:
@@ -98,7 +101,7 @@ Running shroud with custom coverage thresholds:
98
101
  ```ruby
99
102
  # Report coverage of modified files, fail if total project coverage is under 80%,
100
103
  # or if any modified file's coverage is under 95%
101
- shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95
104
+ shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
102
105
  ```
103
106
 
104
107
  Warn on builds instead of fail:
@@ -106,7 +109,7 @@ Warn on builds instead of fail:
106
109
  ```ruby
107
110
  # Report coverage of modified files the same as the above example, except the
108
111
  # builds will only warn instead of fail if below thresholds
109
- shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95, false, false
112
+ shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
110
113
  ```
111
114
 
112
115
  ## Development
@@ -115,4 +118,24 @@ shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95, false, f
115
118
  2. Run `bundle install` to setup dependencies.
116
119
  3. Run `bundle exec rake spec` to run the tests.
117
120
  4. Use `bundle exec guard` to automatically have tests run as you make changes.
118
- 5. Make your changes.
121
+ 5. Make your changes.
122
+
123
+ ## Versioning
124
+
125
+ This repository conforms to the semantic versioning convention:
126
+
127
+ ```
128
+ v[MAJOR].[MINOR].[PATCH]
129
+ ```
130
+
131
+ where
132
+
133
+ [MAJOR] is incremented when an incompatible API change is made or a major milestone that significantly changes the library is achieved.
134
+
135
+ [MINOR] is incremented when new functionality is introduced in a backward-compatible manner.
136
+
137
+ [PATCH] is incremented when a backward-compatible bug fix is introduced.
138
+
139
+ All updates should have a corresponding CHANGELOG.md entry that at a high-level describes what is being newly introduced in it.
140
+
141
+ When incrementing a level any lower-levels should always reset to 0.
@@ -1,3 +1,3 @@
1
1
  module Shroud
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "1.0.0".freeze
3
3
  end
data/lib/shroud/plugin.rb CHANGED
@@ -11,70 +11,59 @@ module Danger
11
11
  #
12
12
  # # Report coverage of modified files, fail if either total project coverage
13
13
  # # or any modified file's coverage is under 90%
14
- # shroud.reportKover 'Project Name', 'path/to/kover/report.xml'
14
+ # shroud.reportKover moduleName: 'Project Name', file: 'path/to/kover/report.xml'
15
15
  #
16
16
  # @example Running Shroud with custom coverage thresholds for Kover
17
17
  #
18
18
  # # Report coverage of modified files, fail if total project coverage is under 80%,
19
19
  # # or if any modified file's coverage is under 95%
20
- # shroud.reportKover 'Project Name', 'path/to/kover/report.xml', 80, 95
20
+ # shroud.reportKover moduleName: 'Project Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
21
21
  #
22
22
  # @example Warn on builds instead of fail for Kover
23
23
  #
24
24
  # # Report coverage of modified files the same as the above example, except the
25
25
  # # builds will only warn instead of fail if below thresholds
26
- # shroud.reportKover 'Project Name', 'path/to/kover/report.xml', 80, 95, false, false
26
+ # shroud.reportKover moduleName: 'Project Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
27
27
  #
28
28
  # @example Running Shroud with default values for Jacoco
29
29
  #
30
30
  # # Report coverage of modified files, fail if either total project coverage
31
31
  # # or any modified file's coverage is under 90%
32
- # shroud.reportJacoco 'Project Name', 'path/to/jacoco/report.xml'
32
+ # shroud.reportJacoco moduleName: 'Project Name', file: 'path/to/jacoco/report.xml'
33
33
  #
34
34
  # @example Running Shroud with custom coverage thresholds for Jacoco
35
35
  #
36
36
  # # Report coverage of modified files, fail if total project coverage is under 80%,
37
37
  # # or if any modified file's coverage is under 95%
38
- # shroud.reportJacoco 'Project Name', 'path/to/jacoco/report.xml', 80, 95
38
+ # shroud.reportJacoco moduleName: 'Project Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
39
39
  #
40
40
  # @example Warn on builds instead of fail for Jacoco
41
41
  #
42
42
  # # Report coverage of modified files the same as the above example, except the
43
43
  # # builds will only warn instead of fail if below thresholds
44
- # shroud.reportJacoco 'Project Name', 'path/to/jacoco/report.xml', 80, 95, false, false
44
+ # shroud.reportJacoco moduleName: 'Project Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
45
45
  #
46
46
  # @tags android, kover, jacoco, coverage
47
47
  #
48
48
  class DangerShroud < Plugin
49
49
 
50
- # <b>DEPRECATED:</b> Please use <tt>reportJacoco</tt> or <tt>reportKover</tt> instead.
50
+ # Defines the method of coverage to be used
51
51
  #
52
- # Report coverage on diffed files, as well as overall coverage.
53
- #
54
- # @param [String] file
55
- # file path to a Jacoco xml coverage report.
56
- #
57
- # @param [Integer] totalProjectThreshold
58
- # defines the required percentage of total project coverage for a passing build.
59
- # default 90.
60
- #
61
- # @param [Integer] modifiedFileThreshold
62
- # defines the required percentage of files modified in a PR for a passing build.
63
- # default 90.
52
+ # * Branch
53
+ # * Class
54
+ # * Instruction
55
+ # * Line
56
+ # * Method
64
57
  #
65
- # @param [Boolean] failIfUnderProjectThreshold
66
- # if true, will fail builds that are under the provided thresholds for the overall project. If false, will only warn.
67
- # default true.
68
- #
69
- # @param [Boolean] failIfUnderFileThreshold
70
- # if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
71
- # default true.
72
- #
73
- # @return [void]
74
- def report(file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold = true, failIfUnderFileThreshold = failIfUnderProjectThreshold)
75
- warn "[DEPRECATION] `report` is deprecated. Please use `reportJacoco` or `reportKover` instead."
76
- reportJacoco('Project', file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold, failIfUnderFileThreshold)
77
- end
58
+ # @example
59
+ # COVERAGE_TYPE[:line] #=> 'LINE'
60
+ COVERAGE_TYPE = {
61
+ branch: 'BRANCH',
62
+ class: 'CLASS',
63
+ instruction: 'INSTRUCTION',
64
+ line: 'LINE',
65
+ method: 'METHOD'
66
+ }.freeze
78
67
 
79
68
  # Report coverage on diffed files, as well as overall coverage.
80
69
  #
@@ -100,9 +89,30 @@ module Danger
100
89
  # if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
101
90
  # default true.
102
91
  #
92
+ # @param [Symbol] coverageType
93
+ # defines the type of coverage to use.
94
+ # default line.
95
+ #
103
96
  # @return [void]
104
- def reportJacoco(moduleName, file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold = true, failIfUnderFileThreshold = false)
105
- internalReport('Jacoco', moduleName, file, totalProjectThreshold, modifiedFileThreshold, failIfUnderProjectThreshold, failIfUnderFileThreshold)
97
+ def reportJacoco(
98
+ moduleName:,
99
+ file:,
100
+ totalProjectThreshold: 90,
101
+ modifiedFileThreshold: 90,
102
+ failIfUnderProjectThreshold: true,
103
+ failIfUnderFileThreshold: failIfUnderProjectThreshold,
104
+ coverageType: :line
105
+ )
106
+ internalReport(
107
+ reportType: 'Jacoco',
108
+ moduleName: moduleName,
109
+ file: file,
110
+ totalProjectThreshold: totalProjectThreshold,
111
+ modifiedFileThreshold: modifiedFileThreshold,
112
+ failIfUnderProjectThreshold: failIfUnderProjectThreshold,
113
+ failIfUnderFileThreshold: failIfUnderFileThreshold,
114
+ coverageType: coverageType
115
+ )
106
116
  end
107
117
 
108
118
  # Report coverage on diffed files, as well as overall coverage.
@@ -129,17 +139,49 @@ module Danger
129
139
  # if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
130
140
  # default true.
131
141
  #
142
+ # @param [Symbol] coverageType
143
+ # defines the type of coverage to use.
144
+ # default line.
145
+ #
132
146
  # @return [void]
133
- def reportKover(moduleName, file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold = true, failIfUnderFileThreshold = failIfUnderProjectThreshold)
134
- internalReport('Kover', moduleName, file, totalProjectThreshold, modifiedFileThreshold, failIfUnderProjectThreshold, failIfUnderFileThreshold)
147
+ def reportKover(
148
+ moduleName:,
149
+ file:,
150
+ totalProjectThreshold: 90,
151
+ modifiedFileThreshold: 90,
152
+ failIfUnderProjectThreshold: true,
153
+ failIfUnderFileThreshold: failIfUnderProjectThreshold,
154
+ coverageType: :line
155
+ )
156
+ internalReport(
157
+ reportType: 'Kover',
158
+ moduleName: moduleName,
159
+ file: file,
160
+ totalProjectThreshold: totalProjectThreshold,
161
+ modifiedFileThreshold: modifiedFileThreshold,
162
+ failIfUnderProjectThreshold: failIfUnderProjectThreshold,
163
+ failIfUnderFileThreshold: failIfUnderFileThreshold,
164
+ coverageType: coverageType
165
+ )
135
166
  end
136
167
 
137
- private def internalReport(reportType, moduleName, file, totalProjectThreshold, modifiedFileThreshold, failIfUnderProjectThreshold, failIfUnderFileThreshold)
168
+ private def internalReport(
169
+ reportType:,
170
+ moduleName:,
171
+ file:,
172
+ totalProjectThreshold:,
173
+ modifiedFileThreshold:,
174
+ failIfUnderProjectThreshold:,
175
+ failIfUnderFileThreshold:,
176
+ coverageType:
177
+ )
138
178
  raise "Please specify file name." if file.empty?
139
179
  raise "No #{reportType} xml report found at #{file}" unless File.exist? file
180
+ coverageMethod = COVERAGE_TYPE[coverageType]
181
+ raise "Undefined coverage type" if coverageMethod.nil?
140
182
  rawXml = File.read(file)
141
183
  parsedXml = Nokogiri::XML.parse(rawXml)
142
- totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='INSTRUCTION']")
184
+ totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='#{coverageMethod}']")
143
185
  missed = totalInstructionCoverage.attr("missed").value.to_i
144
186
  covered = totalInstructionCoverage.attr("covered").value.to_i
145
187
  total = missed + covered
@@ -156,7 +198,7 @@ module Danger
156
198
  touchedFilesHash = {}
157
199
 
158
200
  touchedFileNames.each do |touchedFileName|
159
- xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='INSTRUCTION']")
201
+ xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='#{coverageMethod}']")
160
202
 
161
203
  if (xmlForFileName.length > 0)
162
204
  missed = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-shroud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrewhaisting
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-30 00:00:00.000000000 Z
11
+ date: 2025-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -176,6 +176,7 @@ files:
176
176
  - ".github/workflows/publish.yml"
177
177
  - ".gitignore"
178
178
  - ".ruby-version"
179
+ - CHANGELOG.md
179
180
  - Gemfile
180
181
  - Gemfile.lock
181
182
  - Guardfile
@@ -194,7 +195,7 @@ homepage: https://github.com/livefront/livefront-shroud-android
194
195
  licenses:
195
196
  - MIT
196
197
  metadata: {}
197
- post_install_message:
198
+ post_install_message:
198
199
  rdoc_options: []
199
200
  require_paths:
200
201
  - lib
@@ -210,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  version: '0'
211
212
  requirements: []
212
213
  rubygems_version: 3.1.4
213
- signing_key:
214
+ signing_key:
214
215
  specification_version: 4
215
216
  summary: A danger plugin for enforcing code coverage via a Jacoco coverage report.
216
217
  test_files: