danger-kover 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccb8421deaaee07d3de9b03a92feff5b4214781fecf0d939e353af609323b280
4
- data.tar.gz: 6e88342df62df29ea4127b038019daa12b82710a56d696534b69cde2e2ebd794
3
+ metadata.gz: 44a53eb966b795cb6793ffa0d4f2be671a55fc2dd445e35dc473cdcea3d96382
4
+ data.tar.gz: 5d775bf7df1da1425092d1af297dd021d34a3f29940c3e973de70731361fb67e
5
5
  SHA512:
6
- metadata.gz: b67f4cdff93b1671aa2cff55e1e7106e049407fe3b64a87b7cfedce29105ab21335e57d4d41c9df2f964eada48dc8aeb5e622b7b1fc36d6218d77a0acb3b999c
7
- data.tar.gz: 739c45b3591cd6e4f9a17e0981d69c9e7de485002078ccc17e01de79b0bad036e1bf2017f77d62cf1b8a4dc2aed4afc4e673f9485b5006d35ecba646cff3410c
6
+ metadata.gz: d5de9eeb0965194cbbeadd598e2207808d51290b27ecb9747e9da44d0b61a320e97f033a2bea72822913bd072a44130a03d12a99bd16e40273375e90bdfe6236
7
+ data.tar.gz: c26878612b9780b6f9046afa40bf2500a1d0067c82fcebbd3393eb83290bdbca225ed29ff0fbd8d6f702f93515fd7583f4e0c71433f5d551b925a42c0015d66c
Binary file
@@ -1,3 +1,3 @@
1
1
  module Kover
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.4".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
@@ -112,48 +132,54 @@ module Danger
112
132
  puts "Here is the touched files coverage hash"
113
133
  puts touchedFilesHash
114
134
 
115
- output = "## 🎯 #{moduleName} Code Coverage: **`#{'%.2f' % coveragePercent}%`**\n"
135
+ output = "### 🎯 #{moduleName} Code Coverage: **`#{'%.2f' % coveragePercent}%`**\n"
116
136
 
117
137
  if touchedFilesHash.empty?
118
- output << "The new and modified files are not part of the Kover coverage report 👀.\n"
138
+ output << "The new and updated files are not part of this module coverage report 👀.\n"
119
139
  else
120
- output << "### Coverage of Modified Files:\n"
140
+ output << "**Modified files:**\n"
121
141
  output << "File | Coverage\n"
122
142
  output << ":-----|:-----:\n"
123
143
  end
124
144
 
125
- # go through each file:
145
+ # Go through each file:
126
146
  touchedFilesHash.sort.each do |fileName, coveragePercent|
127
147
  output << "`#{fileName}` | **`#{'%.2f' % coveragePercent}%`**\n"
128
148
 
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
149
+ # Check file coverage
150
+ if (coveragePercent == 0)
151
+ advise("Oops! #{fileName} does not have any test coverage.")
152
+ elsif (coveragePercent < file_threshold)
153
+ advise("Oops! #{fileName} is under #{file_threshold}% coverage.")
137
154
  end
138
155
  end
139
156
 
140
- output << "\n"
141
- output << "Number of files not found in coverage report: #{fileNamesNotInReport.size}."
142
- output << "\n\n"
157
+ if (count_not_found)
158
+ output << "\n\n"
159
+ output << "Number of files not found in coverage report: #{fileNamesNotInReport.size}."
160
+ end
143
161
 
144
- output << 'Code coverage by [danger-kover](https://github.com/JCarlosR/danger-kover).'
162
+ if (link_repository)
163
+ output << "\n\n"
164
+ output << 'Code coverage by [danger-kover](https://github.com/JCarlosR/danger-kover).'
165
+ end
166
+
145
167
  markdown output
146
168
 
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
169
+ # Check total coverage
170
+ if (coveragePercent < total_threshold)
171
+ advise("Oops! The module #{moduleName} codebase is under #{total_threshold}% coverage.")
156
172
  end
157
173
  end
174
+
175
+ # Warn or fail, depending on the `fail_if_under_threshold` flag.
176
+ private def advise(message)
177
+ if (fail_if_under_threshold)
178
+ fail message
179
+ else
180
+ warn message
181
+ end
182
+ end
183
+
158
184
  end
159
185
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrewhaisting
@@ -184,6 +184,7 @@ 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
187
188
  - danger-kover.gemspec
188
189
  - images/bannerImage.png
189
190
  - lib/danger_plugin.rb