danger-code_coverage 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -11
- data/CHANGELOG.md +4 -0
- data/lib/code_coverage/coverage_parser.rb +1 -1
- data/lib/code_coverage/gem_version.rb +1 -1
- data/lib/code_coverage/plugin.rb +8 -3
- data/spec/assets/coverage_jacoco_no_data.json +226 -0
- data/spec/code_coverage_spec.rb +18 -2
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f8c1cbdf5d0b6864186f29788385e7b745c6b4f4fb94e9ab80ddd5c3b4a52c
|
4
|
+
data.tar.gz: 6fbc3bb126d30d66d8464e14d3476392506b442aa75feff0e27d3b3cae58020b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '01839299c25eb0b3c6ed3d07a27ff11a5988c72ab6ed0deddf7f44037ac478d91e2b6371bbb21ce681779ccafccefdd808882bd308f8162f32ad98021cf5cda0'
|
7
|
+
data.tar.gz: ad06067bcf5b764d6dff81854e087ec4a03d2391f771eaa56cc82fab78ddff23b9e8ae10df332be086e7beffd09891f4d28a218e34982b1d9c2bb3436fbcc58f
|
data/.rubocop.yml
CHANGED
@@ -1624,7 +1624,7 @@ Lint/UnifiedInteger:
|
|
1624
1624
|
Enabled: true
|
1625
1625
|
VersionAdded: '0.43'
|
1626
1626
|
|
1627
|
-
Lint/
|
1627
|
+
Lint/RedundantCopDisableDirective:
|
1628
1628
|
Description: >-
|
1629
1629
|
Checks for rubocop:disable comments that can be removed.
|
1630
1630
|
Note: this cop is not disabled when disabling all cops.
|
@@ -1632,20 +1632,19 @@ Lint/UnneededCopDisableDirective:
|
|
1632
1632
|
Enabled: true
|
1633
1633
|
VersionAdded: '0.53'
|
1634
1634
|
|
1635
|
-
Lint/
|
1635
|
+
Lint/RedundantCopEnableDirective:
|
1636
1636
|
Description: Checks for rubocop:enable comments that can be removed.
|
1637
1637
|
Enabled: true
|
1638
1638
|
VersionAdded: '0.53'
|
1639
1639
|
|
1640
|
-
Lint/
|
1640
|
+
Lint/RedundantRequireStatement:
|
1641
1641
|
Description: 'Checks for unnecessary `require` statement.'
|
1642
1642
|
Enabled: true
|
1643
1643
|
VersionAdded: '0.51'
|
1644
1644
|
|
1645
|
-
Lint/
|
1645
|
+
Lint/RedundantSplatExpansion:
|
1646
1646
|
Description: 'Checks for splat unnecessarily being called on literals.'
|
1647
1647
|
Enabled: true
|
1648
|
-
VersionAdded: '0.43'
|
1649
1648
|
|
1650
1649
|
Lint/UnreachableCode:
|
1651
1650
|
Description: 'Unreachable code.'
|
@@ -3763,29 +3762,28 @@ Style/UnlessElse:
|
|
3763
3762
|
Enabled: true
|
3764
3763
|
VersionAdded: '0.9'
|
3765
3764
|
|
3766
|
-
Style/
|
3765
|
+
Style/RedundantCapitalW:
|
3767
3766
|
Description: 'Checks for %W when interpolation is not needed.'
|
3768
3767
|
Enabled: true
|
3769
3768
|
VersionAdded: '0.21'
|
3770
|
-
VersionChanged: '0.24'
|
3771
3769
|
|
3772
|
-
Style/
|
3770
|
+
Style/RedundantCondition:
|
3773
3771
|
Description: 'Checks for unnecessary conditional expressions.'
|
3774
3772
|
Enabled: true
|
3775
3773
|
VersionAdded: '0.57'
|
3776
3774
|
|
3777
|
-
Style/
|
3775
|
+
Style/RedundantInterpolation:
|
3778
3776
|
Description: 'Checks for strings that are just an interpolated expression.'
|
3779
3777
|
Enabled: true
|
3780
3778
|
VersionAdded: '0.36'
|
3781
3779
|
|
3782
|
-
Style/
|
3780
|
+
Style/RedundantPercentQ:
|
3783
3781
|
Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
|
3784
3782
|
StyleGuide: '#percent-q'
|
3785
3783
|
Enabled: true
|
3786
3784
|
VersionAdded: '0.24'
|
3787
3785
|
|
3788
|
-
Style/
|
3786
|
+
Style/RedundantSort:
|
3789
3787
|
Description: >-
|
3790
3788
|
Use `min` instead of `sort.first`,
|
3791
3789
|
`max_by` instead of `sort_by...last`, etc.
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.0.1] - 2019-11-07
|
8
|
+
### Fixed
|
9
|
+
- Fix crash if an item has no data
|
10
|
+
|
7
11
|
## [1.0.0] - 2019-6-26
|
8
12
|
### Fixed
|
9
13
|
- Catch all errors while parsing url content
|
data/lib/code_coverage/plugin.rb
CHANGED
@@ -51,8 +51,9 @@ module Danger
|
|
51
51
|
options = args.first
|
52
52
|
sort_order = options && options[:sort]
|
53
53
|
if sort_order && !sort_order.eql?(:ascending) && !sort_order.eql?(:descending)
|
54
|
-
raise(ArgumentError
|
54
|
+
raise(ArgumentError.new('Invalid configuration, use [:ascending, :descending]'))
|
55
55
|
end
|
56
|
+
|
56
57
|
check_auth(options)
|
57
58
|
|
58
59
|
items = coverage_items
|
@@ -121,7 +122,11 @@ module Danger
|
|
121
122
|
sum += convert_entry(item.instruction)
|
122
123
|
end
|
123
124
|
|
124
|
-
|
125
|
+
if count.zero?
|
126
|
+
0.0
|
127
|
+
else
|
128
|
+
(sum / count).round(2)
|
129
|
+
end
|
125
130
|
end
|
126
131
|
|
127
132
|
def auth_user(options)
|
@@ -158,7 +163,7 @@ module Danger
|
|
158
163
|
end
|
159
164
|
|
160
165
|
def coverage_json
|
161
|
-
options = {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}
|
166
|
+
options = { ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
162
167
|
options[:http_basic_authentication] = [@auth[:user], @auth[:token]] if @auth
|
163
168
|
OpenURI.open_uri("#{ENV['BUILD_URL']}/coverage/result/api/json?depth=5", options).read
|
164
169
|
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
{
|
2
|
+
"_class": "io.jenkins.plugins.coverage.targets.CoverageResult",
|
3
|
+
"results": {
|
4
|
+
"children": [
|
5
|
+
{
|
6
|
+
"children": [
|
7
|
+
{
|
8
|
+
"children": [
|
9
|
+
{
|
10
|
+
"children": [
|
11
|
+
{
|
12
|
+
"children": [
|
13
|
+
{},
|
14
|
+
{}
|
15
|
+
],
|
16
|
+
"elements": [
|
17
|
+
{
|
18
|
+
"denominator": 2.0,
|
19
|
+
"name": "Class",
|
20
|
+
"numerator": 0.0,
|
21
|
+
"ratio": 0.0
|
22
|
+
}
|
23
|
+
],
|
24
|
+
"name": "MainActivity.java"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"elements": [
|
28
|
+
{
|
29
|
+
"denominator": 3.0,
|
30
|
+
"name": "File",
|
31
|
+
"numerator": 1.0,
|
32
|
+
"ratio": 33.333332
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"denominator": 4.0,
|
36
|
+
"name": "Class",
|
37
|
+
"numerator": 1.0,
|
38
|
+
"ratio": 25.0
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"denominator": 15.0,
|
42
|
+
"name": "Method",
|
43
|
+
"numerator": 1.0,
|
44
|
+
"ratio": 6.6666665
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"denominator": 110.0,
|
48
|
+
"name": "Instruction",
|
49
|
+
"numerator": 6.0,
|
50
|
+
"ratio": 5.4545455
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"denominator": 34.0,
|
54
|
+
"name": "Line",
|
55
|
+
"numerator": 1.0,
|
56
|
+
"ratio": 2.9411764
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"denominator": 6.0,
|
60
|
+
"name": "Conditional",
|
61
|
+
"numerator": 2.0,
|
62
|
+
"ratio": 33.333332
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"name": "com/example/kyaak/myapplication"
|
66
|
+
}
|
67
|
+
],
|
68
|
+
"elements": [
|
69
|
+
{
|
70
|
+
"denominator": 5.0,
|
71
|
+
"name": "Package",
|
72
|
+
"numerator": 3.0,
|
73
|
+
"ratio": 60.0
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"denominator": 18.0,
|
77
|
+
"name": "File",
|
78
|
+
"numerator": 3.0,
|
79
|
+
"ratio": 16.666666
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"denominator": 21.0,
|
83
|
+
"name": "Class",
|
84
|
+
"numerator": 3.0,
|
85
|
+
"ratio": 14.285714
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"denominator": 193.0,
|
89
|
+
"name": "Method",
|
90
|
+
"numerator": 6.0,
|
91
|
+
"ratio": 3.1088083
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"denominator": 2169.0,
|
95
|
+
"name": "Instruction",
|
96
|
+
"numerator": 52.0,
|
97
|
+
"ratio": 2.3974183
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"denominator": 296.0,
|
101
|
+
"name": "Line",
|
102
|
+
"numerator": 9.0,
|
103
|
+
"ratio": 3.0405405
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"denominator": 178.0,
|
107
|
+
"name": "Conditional",
|
108
|
+
"numerator": 3.0,
|
109
|
+
"ratio": 1.6853932
|
110
|
+
}
|
111
|
+
],
|
112
|
+
"name": "project"
|
113
|
+
}
|
114
|
+
],
|
115
|
+
"elements": [
|
116
|
+
{
|
117
|
+
"denominator": 1.0,
|
118
|
+
"name": "Group",
|
119
|
+
"numerator": 1.0,
|
120
|
+
"ratio": 100.0
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"denominator": 5.0,
|
124
|
+
"name": "Package",
|
125
|
+
"numerator": 3.0,
|
126
|
+
"ratio": 60.0
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"denominator": 18.0,
|
130
|
+
"name": "File",
|
131
|
+
"numerator": 3.0,
|
132
|
+
"ratio": 16.666666
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"denominator": 21.0,
|
136
|
+
"name": "Class",
|
137
|
+
"numerator": 3.0,
|
138
|
+
"ratio": 14.285714
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"denominator": 193.0,
|
142
|
+
"name": "Method",
|
143
|
+
"numerator": 6.0,
|
144
|
+
"ratio": 3.1088083
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"denominator": 2169.0,
|
148
|
+
"name": "Instruction",
|
149
|
+
"numerator": 52.0,
|
150
|
+
"ratio": 2.3974183
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"denominator": 296.0,
|
154
|
+
"name": "Line",
|
155
|
+
"numerator": 9.0,
|
156
|
+
"ratio": 3.0405405
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"denominator": 178.0,
|
160
|
+
"name": "Conditional",
|
161
|
+
"numerator": 3.0,
|
162
|
+
"ratio": 1.6853932
|
163
|
+
}
|
164
|
+
],
|
165
|
+
"name": "code_quality: jacoco.xml"
|
166
|
+
}
|
167
|
+
],
|
168
|
+
"elements": [
|
169
|
+
{
|
170
|
+
"denominator": 1.0,
|
171
|
+
"name": "Report",
|
172
|
+
"numerator": 1.0,
|
173
|
+
"ratio": 100.0
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"denominator": 1.0,
|
177
|
+
"name": "Group",
|
178
|
+
"numerator": 1.0,
|
179
|
+
"ratio": 100.0
|
180
|
+
},
|
181
|
+
{
|
182
|
+
"denominator": 5.0,
|
183
|
+
"name": "Package",
|
184
|
+
"numerator": 3.0,
|
185
|
+
"ratio": 60.0
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"denominator": 18.0,
|
189
|
+
"name": "File",
|
190
|
+
"numerator": 3.0,
|
191
|
+
"ratio": 16.666666
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"denominator": 21.0,
|
195
|
+
"name": "Class",
|
196
|
+
"numerator": 3.0,
|
197
|
+
"ratio": 14.285714
|
198
|
+
},
|
199
|
+
{
|
200
|
+
"denominator": 193.0,
|
201
|
+
"name": "Method",
|
202
|
+
"numerator": 6.0,
|
203
|
+
"ratio": 3.1088083
|
204
|
+
},
|
205
|
+
{
|
206
|
+
"denominator": 2169.0,
|
207
|
+
"name": "Instruction",
|
208
|
+
"numerator": 52.0,
|
209
|
+
"ratio": 2.3974183
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"denominator": 296.0,
|
213
|
+
"name": "Line",
|
214
|
+
"numerator": 9.0,
|
215
|
+
"ratio": 3.0405405
|
216
|
+
},
|
217
|
+
{
|
218
|
+
"denominator": 178.0,
|
219
|
+
"name": "Conditional",
|
220
|
+
"numerator": 3.0,
|
221
|
+
"ratio": 1.6853932
|
222
|
+
}
|
223
|
+
],
|
224
|
+
"name": "All reports"
|
225
|
+
}
|
226
|
+
}
|
data/spec/code_coverage_spec.rb
CHANGED
@@ -88,6 +88,22 @@ module Danger
|
|
88
88
|
expect(entries[2]).to(eq('50.94'))
|
89
89
|
end
|
90
90
|
|
91
|
+
it 'total returns 0 if no coverage data' do
|
92
|
+
mock_coverage_json('/assets/coverage_jacoco_no_data.json')
|
93
|
+
mock_file_in_changeset(true)
|
94
|
+
|
95
|
+
@plugin.report
|
96
|
+
markdowns = @dangerfile.status_report[:markdowns]
|
97
|
+
expect(markdowns.length).to(be(1))
|
98
|
+
lines = markdowns.first.message.split("\n")
|
99
|
+
entries = lines[4].split('|')
|
100
|
+
expect(entries[2]).to(eq('0.0'))
|
101
|
+
expect(entries[3]).to(eq('-'))
|
102
|
+
expect(entries[4]).to(eq('-'))
|
103
|
+
expect(entries[5]).to(eq('-'))
|
104
|
+
expect(entries[6]).to(eq('-'))
|
105
|
+
end
|
106
|
+
|
91
107
|
it 'ignores empty column in total' do
|
92
108
|
mock_coverage_json('/assets/coverage_jacoco_no_conditional.json')
|
93
109
|
mock_file_in_changeset(true)
|
@@ -157,11 +173,11 @@ module Danger
|
|
157
173
|
|
158
174
|
it 'throws error if sort config invalid' do
|
159
175
|
mock_coverage_json('/assets/coverage_jacoco_single.json')
|
160
|
-
expect
|
176
|
+
expect do
|
161
177
|
@plugin.report(
|
162
178
|
sort: :invalid
|
163
179
|
)
|
164
|
-
|
180
|
+
end.to(raise_error(%r{:ascending, :descending}))
|
165
181
|
end
|
166
182
|
|
167
183
|
it 'finds changed file in subdirectory' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-code_coverage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyaak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- spec/assets/coverage_jacoco.json
|
195
195
|
- spec/assets/coverage_jacoco_multiple_unordered.json
|
196
196
|
- spec/assets/coverage_jacoco_no_conditional.json
|
197
|
+
- spec/assets/coverage_jacoco_no_data.json
|
197
198
|
- spec/assets/coverage_jacoco_single.json
|
198
199
|
- spec/assets/coverage_no_files.json
|
199
200
|
- spec/assets/missing_json.html
|
@@ -219,7 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
220
|
- !ruby/object:Gem::Version
|
220
221
|
version: '0'
|
221
222
|
requirements: []
|
222
|
-
|
223
|
+
rubyforge_project:
|
224
|
+
rubygems_version: 2.7.7
|
223
225
|
signing_key:
|
224
226
|
specification_version: 4
|
225
227
|
summary: Read Jenkins code-coverage reports and comment pull request with coverage
|
@@ -231,6 +233,7 @@ test_files:
|
|
231
233
|
- spec/assets/coverage_jacoco.json
|
232
234
|
- spec/assets/coverage_jacoco_multiple_unordered.json
|
233
235
|
- spec/assets/coverage_jacoco_no_conditional.json
|
236
|
+
- spec/assets/coverage_jacoco_no_data.json
|
234
237
|
- spec/assets/coverage_jacoco_single.json
|
235
238
|
- spec/assets/coverage_no_files.json
|
236
239
|
- spec/assets/missing_json.html
|