danger-kover 0.0.3 → 0.0.5

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: ccb8421deaaee07d3de9b03a92feff5b4214781fecf0d939e353af609323b280
4
- data.tar.gz: 6e88342df62df29ea4127b038019daa12b82710a56d696534b69cde2e2ebd794
3
+ metadata.gz: d1cbf44af41b300b520376b5a926a694936ceb469340cd7a0de06efc0d0e7b8e
4
+ data.tar.gz: 04eb0e742c15937f5b7edd6b5a0e3174e900e3a3777ce8f93a8527081e3f630e
5
5
  SHA512:
6
- metadata.gz: b67f4cdff93b1671aa2cff55e1e7106e049407fe3b64a87b7cfedce29105ab21335e57d4d41c9df2f964eada48dc8aeb5e622b7b1fc36d6218d77a0acb3b999c
7
- data.tar.gz: 739c45b3591cd6e4f9a17e0981d69c9e7de485002078ccc17e01de79b0bad036e1bf2017f77d62cf1b8a4dc2aed4afc4e673f9485b5006d35ecba646cff3410c
6
+ metadata.gz: a891c1fe7627631ecdf0d67f5c233aaab0b7f25cab395fc603db83d7f26e99f3ebeeadbbdf1263fe47004428ad4b2e74675bd722787f9a3b5d9adabc2478d737
7
+ data.tar.gz: 6f46c114ea07714b695e6fae674a8711e069b0fc7960d156ce854e45a156fd08c79f14a6ea697073f5b87b3cb66f12abdada896a8dc4716b1d8833d2b732cb3c
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module Kover
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
data/lib/kover/plugin.rb CHANGED
@@ -60,6 +60,26 @@ module Danger
60
60
  @fail_if_under_threshold ||= true
61
61
  end
62
62
 
63
+ # Show plugin repository link.
64
+ # @return [Boolean]
65
+ attr_accessor :link_repository
66
+
67
+ # A getter for `link_repository`, returning `true` by default.
68
+ # @return [Boolean]
69
+ def link_repository
70
+ @link_repository ||= true
71
+ end
72
+
73
+ # Show not found files in report count.
74
+ # @return [Boolean]
75
+ attr_accessor :count_not_found
76
+
77
+ # A getter for `count_not_found`, returning `true` by default.
78
+ # @return [Boolean]
79
+ def count_not_found
80
+ @count_not_found ||= true
81
+ end
82
+
63
83
  # Report coverage on diffed files, as well as overall coverage.
64
84
  #
65
85
  # @param [String] moduleName
@@ -109,51 +129,58 @@ module Danger
109
129
 
110
130
  puts "Here are unreported files"
111
131
  puts fileNamesNotInReport.to_s
132
+
112
133
  puts "Here is the touched files coverage hash"
113
134
  puts touchedFilesHash
114
135
 
115
- output = "## 🎯 #{moduleName} Code Coverage: **`#{'%.2f' % coveragePercent}%`**\n"
136
+ output = "### 🎯 #{moduleName} Code Coverage: **`#{'%.2f' % coveragePercent}%`**\n\n"
116
137
 
117
138
  if touchedFilesHash.empty?
118
- output << "The new and modified files are not part of the Kover coverage report 👀.\n"
139
+ output << "The new and updated files are not part of this module coverage report 👀.\n"
119
140
  else
120
- output << "### Coverage of Modified Files:\n"
141
+ output << "**Modified files:**\n\n"
121
142
  output << "File | Coverage\n"
122
143
  output << ":-----|:-----:\n"
123
144
  end
124
145
 
125
- # go through each file:
146
+ # Go through each file:
126
147
  touchedFilesHash.sort.each do |fileName, coveragePercent|
127
148
  output << "`#{fileName}` | **`#{'%.2f' % coveragePercent}%`**\n"
128
149
 
129
- # warn or fail if under specified file threshold:
130
- if (coveragePercent < file_threshold)
131
- warningMessage = "Uh oh! #{fileName} is under #{file_threshold}% coverage!"
132
- if (fail_if_under_threshold)
133
- fail warningMessage
134
- else
135
- warn warningMessage
136
- end
150
+ # Check file coverage
151
+ if (coveragePercent == 0)
152
+ advise("Oops! #{fileName} does not have any test coverage.")
153
+ elsif (coveragePercent < file_threshold)
154
+ advise("Oops! #{fileName} is under #{file_threshold}% coverage.")
137
155
  end
138
156
  end
139
157
 
140
- output << "\n"
141
- output << "Number of files not found in coverage report: #{fileNamesNotInReport.size}."
142
- output << "\n\n"
158
+ if (count_not_found)
159
+ output << "\n\n"
160
+ output << "Number of files not found in coverage report: #{fileNamesNotInReport.size}."
161
+ end
143
162
 
144
- output << 'Code coverage by [danger-kover](https://github.com/JCarlosR/danger-kover).'
163
+ if (link_repository)
164
+ output << "\n\n"
165
+ output << 'Code coverage by [danger-kover](https://github.com/JCarlosR/danger-kover).'
166
+ end
167
+
145
168
  markdown output
146
169
 
147
- # warn or fail if total coverage is under specified threshold
148
- if (coveragePercent < total_threshold)
149
- totalCoverageWarning = "Oops! The module #{moduleName} codebase is under #{total_threshold}% coverage."
150
-
151
- if (fail_if_under_threshold)
152
- fail totalCoverageWarning
153
- else
154
- warn totalCoverageWarning
155
- end
170
+ # Check total coverage
171
+ if (coveragePercent < total_threshold)
172
+ advise("Oops! The module #{moduleName} codebase is under #{total_threshold}% coverage.")
156
173
  end
157
174
  end
175
+
176
+ # Warn or fail, depending on the `fail_if_under_threshold` flag.
177
+ private def advise(message)
178
+ if (fail_if_under_threshold)
179
+ fail message
180
+ else
181
+ warn message
182
+ end
183
+ end
184
+
158
185
  end
159
186
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-kover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrewhaisting
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-22 00:00:00.000000000 Z
11
+ date: 2023-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -184,6 +184,8 @@ files:
184
184
  - Rakefile
185
185
  - danger-kover-0.0.1.gem
186
186
  - danger-kover-0.0.2.gem
187
+ - danger-kover-0.0.3.gem
188
+ - danger-kover-0.0.4.gem
187
189
  - danger-kover.gemspec
188
190
  - images/bannerImage.png
189
191
  - lib/danger_plugin.rb