undercover 0.4.6 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +7 -5
- data/.rubocop.yml +2 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +18 -1
- data/Gemfile +11 -0
- data/README.md +8 -7
- data/lib/undercover/changeset.rb +2 -2
- data/lib/undercover/formatter.rb +6 -6
- data/lib/undercover/result.rb +6 -6
- data/lib/undercover/version.rb +1 -1
- data/undercover.gemspec +5 -16
- metadata +21 -132
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba2a988ce8b2ef9451615675538b268f4d663cb141288a646b2604785ea92dc6
|
4
|
+
data.tar.gz: 6822d32d0b2000e711194c0d595b2f69dcaa3020740db9613be8f6fceea1e4e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ada6a585eee4ff30f9a520dde96f0b3b74bd11ab05a9e7857b356da7c00519e81d36dda12ddd4c7afde81b23cb73bc1c88a35f2f559f1cf9a638c42eab48052
|
7
|
+
data.tar.gz: 6c846695987c6126e7db5c7c363e44756f57aaf34374157bd35c0e723469f705a625244e90818a39b07e5626df8b34f248796405f95a5c9ed884e4760af304f3
|
data/.github/workflows/ruby.yml
CHANGED
@@ -5,9 +5,11 @@ jobs:
|
|
5
5
|
runs-on: ubuntu-latest
|
6
6
|
strategy:
|
7
7
|
matrix:
|
8
|
-
ruby: ['3.
|
8
|
+
ruby: ['3.3', '3.0']
|
9
9
|
steps:
|
10
|
-
- uses: actions/checkout@
|
10
|
+
- uses: actions/checkout@v3
|
11
|
+
with:
|
12
|
+
fetch-depth: 0 # fetch all since test fixtures depend on history
|
11
13
|
- name: Set up Ruby ${{ matrix.ruby }}
|
12
14
|
uses: ruby/setup-ruby@v1
|
13
15
|
with:
|
@@ -19,9 +21,9 @@ jobs:
|
|
19
21
|
bundle exec rake
|
20
22
|
- name: undercover (local)
|
21
23
|
run: |
|
22
|
-
git fetch origin master:master
|
24
|
+
git fetch --update-head-ok origin master:master
|
23
25
|
undercover --compare master
|
24
|
-
- uses: actions/upload-artifact@
|
26
|
+
- uses: actions/upload-artifact@v3
|
25
27
|
with:
|
26
28
|
name: undercover.lcov
|
27
29
|
path: coverage/lcov/undercover.lcov
|
@@ -29,7 +31,7 @@ jobs:
|
|
29
31
|
runs-on: ubuntu-latest
|
30
32
|
needs: build
|
31
33
|
steps:
|
32
|
-
- uses: actions/download-artifact@
|
34
|
+
- uses: actions/download-artifact@v3
|
33
35
|
with:
|
34
36
|
name: undercover.lcov
|
35
37
|
- name: Upload coverage
|
data/.rubocop.yml
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.3.0
|
data/CHANGELOG.md
CHANGED
@@ -6,8 +6,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
# [0.5.0] - 2024-01-09
|
10
|
+
### Changed
|
11
|
+
- Drop ruby 2.x support, require ruby 3.x in gemspec
|
12
|
+
- Dev dependency updates
|
13
|
+
|
14
|
+
# [0.4.7] - 2024-01-08
|
15
|
+
### Fixed
|
16
|
+
- [Update of one-line block is ignored](https://github.com/grodowski/undercover/pull/207) by [@lizhangyuh](https://github.com/lizhangyuh)
|
17
|
+
|
18
|
+
# [0.4.6] - 2023-04-21
|
19
|
+
### Added
|
20
|
+
- #total_coverage and #total_branch_coverage in the LcovParser
|
21
|
+
|
9
22
|
### Changed
|
10
23
|
- Drop support for ruby < 2.7
|
24
|
+
- Test coverage with both local `undercover` and Undercover GitHub App for demo purposes
|
11
25
|
|
12
26
|
# [0.4.5] - 2022-07-28
|
13
27
|
### Changed
|
@@ -114,7 +128,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
114
128
|
### Added
|
115
129
|
- First release of `undercover` 🎉
|
116
130
|
|
117
|
-
[Unreleased]: https://github.com/grodowski/undercover/compare/v0.
|
131
|
+
[Unreleased]: https://github.com/grodowski/undercover/compare/v0.5.0...HEAD
|
132
|
+
[0.5.0]: https://github.com/grodowski/undercover/compare/v0.4.7...v0.5.0
|
133
|
+
[0.4.7]: https://github.com/grodowski/undercover/compare/v0.4.6...v0.4.7
|
134
|
+
[0.4.6]: https://github.com/grodowski/undercover/compare/v0.4.5...v0.4.6
|
118
135
|
[0.4.5]: https://github.com/grodowski/undercover/compare/v0.4.4...v0.4.5
|
119
136
|
[0.4.4]: https://github.com/grodowski/undercover/compare/v0.4.3...v0.4.4
|
120
137
|
[0.4.3]: https://github.com/grodowski/undercover/compare/v0.4.1...v0.4.3
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
|
1
|
+
![logo](https://github.com/grodowski/undercover/assets/4991698/c4bf038b-4472-4406-8f1f-5ddc812908d6)
|
2
2
|
|
3
|
-
|
4
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/b403feed68a18c072ec5/maintainability)](https://codeclimate.com/github/grodowski/undercover/maintainability)
|
5
|
-
![Downloads](https://img.shields.io/gem/dt/undercover)
|
3
|
+
`undercover` warns about methods, classes and blocks that **were changed without tests**, to help you easily find untested code and reduce the number of bugs. It does so by analysing data from git diffs, code structure and SimpleCov coverage reports.
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
Works with CI/CD and automated pull request review, as well as locally using the CLI to help you reduce the number of defects caused by untested code changes.
|
5
|
+
Works with any Ruby CI pipeline as well as locally as a CLI.
|
10
6
|
|
11
7
|
- Visit **[https://undercover-ci.com](https://undercover-ci.com)** to set up code review checks with the GitHub App, or use one of the [CI integrations](#code-review-integrations)
|
12
8
|
- Learn how to find untested code changes locally with the [CLI](#usage)
|
13
9
|
|
10
|
+
|
11
|
+
[![Build Status](https://github.com/grodowski/undercover/actions/workflows/ruby.yml/badge.svg)](https://github.com/grodowski/undercover/actions)
|
12
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/b403feed68a18c072ec5/maintainability)](https://codeclimate.com/github/grodowski/undercover/maintainability)
|
13
|
+
![Downloads](https://img.shields.io/gem/dt/undercover)
|
14
|
+
|
14
15
|
A sample output of `undercover` ran before a commit may look like this:
|
15
16
|
|
16
17
|
![screenshot warning](docs/screenshot_warnings.png)
|
data/lib/undercover/changeset.rb
CHANGED
@@ -56,10 +56,10 @@ module Undercover
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# TODO: refactor to a standalone validator (depending on changeset AND lcov)
|
59
|
-
# TODO: add specs
|
60
59
|
def validate(lcov_report_path)
|
61
60
|
return :no_changes if files.empty?
|
62
|
-
|
61
|
+
|
62
|
+
:stale_coverage if last_modified > File.mtime(lcov_report_path)
|
63
63
|
end
|
64
64
|
|
65
65
|
private
|
data/lib/undercover/formatter.rb
CHANGED
@@ -17,21 +17,21 @@ module Undercover
|
|
17
17
|
def formatted_warnings
|
18
18
|
@results.map.with_index(1) do |res, idx|
|
19
19
|
"🚨 #{idx}) node `#{res.node.name}` type: #{res.node.human_name},\n" +
|
20
|
-
(' ' * pad_size) + "loc: #{res.file_path_with_lines}," \
|
21
|
-
"
|
20
|
+
(' ' * pad_size) + "loc: #{res.file_path_with_lines}, " \
|
21
|
+
"coverage: #{res.coverage_f * 100}%\n" +
|
22
22
|
res.pretty_print
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def success
|
27
|
-
"#{Rainbow('undercover').bold.green}: ✅ No coverage" \
|
28
|
-
'
|
27
|
+
"#{Rainbow('undercover').bold.green}: ✅ No coverage " \
|
28
|
+
'is missing in latest changes'
|
29
29
|
end
|
30
30
|
|
31
31
|
def warnings_header
|
32
32
|
"#{Rainbow('undercover').bold.red}: " \
|
33
|
-
'👮♂️ some methods have no test coverage! Please add specs for' \
|
34
|
-
'
|
33
|
+
'👮♂️ some methods have no test coverage! Please add specs for ' \
|
34
|
+
'methods listed below'
|
35
35
|
end
|
36
36
|
|
37
37
|
def pad_size
|
data/lib/undercover/result.rb
CHANGED
@@ -13,7 +13,7 @@ module Undercover
|
|
13
13
|
def initialize(node, file_cov, file_path)
|
14
14
|
@node = node
|
15
15
|
@coverage = file_cov.select do |ln, _|
|
16
|
-
ln > first_line && ln < last_line
|
16
|
+
first_line == last_line ? ln == first_line : ln > first_line && ln < last_line
|
17
17
|
end
|
18
18
|
@file_path = file_path
|
19
19
|
@flagged = false
|
@@ -54,7 +54,7 @@ module Undercover
|
|
54
54
|
lines[ln] = 0
|
55
55
|
end
|
56
56
|
end
|
57
|
-
return 1.0 if lines.keys.
|
57
|
+
return 1.0 if lines.keys.empty?
|
58
58
|
|
59
59
|
(lines.values.sum.to_f / lines.keys.size).round(4)
|
60
60
|
end
|
@@ -84,7 +84,7 @@ module Undercover
|
|
84
84
|
pad = node.last_line.to_s.length
|
85
85
|
pretty_print_lines.map do |covered, (num, line)|
|
86
86
|
formatted_line = "#{num.to_s.rjust(pad)}: #{line}"
|
87
|
-
if line.strip.
|
87
|
+
if line.strip.empty?
|
88
88
|
Rainbow(formatted_line).darkgray.dark
|
89
89
|
elsif covered.nil?
|
90
90
|
Rainbow(formatted_line).darkgray.dark + \
|
@@ -107,8 +107,8 @@ module Undercover
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def inspect
|
110
|
-
"#<Undercover::Report::Result:#{object_id}" \
|
111
|
-
"
|
110
|
+
"#<Undercover::Report::Result:#{object_id} " \
|
111
|
+
"name: #{node.name}, coverage: #{coverage_f}>"
|
112
112
|
end
|
113
113
|
alias to_s inspect
|
114
114
|
|
@@ -119,7 +119,7 @@ module Undercover
|
|
119
119
|
branches = coverage.select { |cov| cov.size == 4 && cov[0] == line_number }
|
120
120
|
count_covered = branches.count { |cov| cov[3].positive? }
|
121
121
|
|
122
|
-
return '' if branches.
|
122
|
+
return '' if branches.empty?
|
123
123
|
|
124
124
|
if count_covered < branches.size
|
125
125
|
Rainbow(' branches: ').italic.darkgray.dark + \
|
data/lib/undercover/version.rb
CHANGED
data/undercover.gemspec
CHANGED
@@ -4,15 +4,14 @@ lib = File.expand_path('lib', __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'undercover/version'
|
6
6
|
|
7
|
-
# rubocop:disable Metrics/BlockLength
|
8
7
|
Gem::Specification.new do |spec|
|
9
8
|
spec.name = 'undercover'
|
10
9
|
spec.version = Undercover::VERSION
|
11
10
|
spec.authors = ['Jan Grodowski']
|
12
11
|
spec.email = ['jgrodowski@gmail.com']
|
13
12
|
|
14
|
-
spec.summary = 'Actionable code coverage - detects untested' \
|
15
|
-
'
|
13
|
+
spec.summary = 'Actionable code coverage - detects untested ' \
|
14
|
+
'code blocks in recent changes'
|
16
15
|
spec.homepage = 'https://github.com/grodowski/undercover'
|
17
16
|
spec.license = 'MIT'
|
18
17
|
spec.metadata = {
|
@@ -26,20 +25,10 @@ Gem::Specification.new do |spec|
|
|
26
25
|
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
27
26
|
spec.require_paths = ['lib']
|
28
27
|
|
29
|
-
spec.required_ruby_version = '>=
|
28
|
+
spec.required_ruby_version = '>= 3.0.0'
|
30
29
|
|
30
|
+
spec.add_dependency 'bigdecimal'
|
31
31
|
spec.add_dependency 'imagen', '>= 0.1.8'
|
32
32
|
spec.add_dependency 'rainbow', '>= 2.1', '< 4.0'
|
33
|
-
spec.add_dependency 'rugged', '>= 0.27', '< 1.
|
34
|
-
|
35
|
-
spec.add_development_dependency 'bundler'
|
36
|
-
spec.add_development_dependency 'pry'
|
37
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
38
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
|
-
spec.add_development_dependency 'rubocop', '~> 1.28.2'
|
40
|
-
spec.add_development_dependency 'simplecov'
|
41
|
-
spec.add_development_dependency 'simplecov-html'
|
42
|
-
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
|
43
|
-
spec.add_development_dependency 'timecop'
|
33
|
+
spec.add_dependency 'rugged', '>= 0.27', '< 1.8'
|
44
34
|
end
|
45
|
-
# rubocop:enable Metrics/BlockLength
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undercover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Grodowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bigdecimal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: imagen
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +67,7 @@ dependencies:
|
|
53
67
|
version: '0.27'
|
54
68
|
- - "<"
|
55
69
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
70
|
+
version: '1.8'
|
57
71
|
type: :runtime
|
58
72
|
prerelease: false
|
59
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -63,133 +77,7 @@ dependencies:
|
|
63
77
|
version: '0.27'
|
64
78
|
- - "<"
|
65
79
|
- !ruby/object:Gem::Version
|
66
|
-
version: '1.
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: bundler
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0'
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: pry
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- - ">="
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0'
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: rake
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '13.0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '13.0'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: rspec
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
112
|
-
requirements:
|
113
|
-
- - "~>"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '3.0'
|
116
|
-
type: :development
|
117
|
-
prerelease: false
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - "~>"
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: '3.0'
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: rubocop
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - "~>"
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 1.28.2
|
130
|
-
type: :development
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - "~>"
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 1.28.2
|
137
|
-
- !ruby/object:Gem::Dependency
|
138
|
-
name: simplecov
|
139
|
-
requirement: !ruby/object:Gem::Requirement
|
140
|
-
requirements:
|
141
|
-
- - ">="
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '0'
|
144
|
-
type: :development
|
145
|
-
prerelease: false
|
146
|
-
version_requirements: !ruby/object:Gem::Requirement
|
147
|
-
requirements:
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '0'
|
151
|
-
- !ruby/object:Gem::Dependency
|
152
|
-
name: simplecov-html
|
153
|
-
requirement: !ruby/object:Gem::Requirement
|
154
|
-
requirements:
|
155
|
-
- - ">="
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
type: :development
|
159
|
-
prerelease: false
|
160
|
-
version_requirements: !ruby/object:Gem::Requirement
|
161
|
-
requirements:
|
162
|
-
- - ">="
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version: '0'
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: simplecov-lcov
|
167
|
-
requirement: !ruby/object:Gem::Requirement
|
168
|
-
requirements:
|
169
|
-
- - "~>"
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
version: '0.8'
|
172
|
-
type: :development
|
173
|
-
prerelease: false
|
174
|
-
version_requirements: !ruby/object:Gem::Requirement
|
175
|
-
requirements:
|
176
|
-
- - "~>"
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
version: '0.8'
|
179
|
-
- !ruby/object:Gem::Dependency
|
180
|
-
name: timecop
|
181
|
-
requirement: !ruby/object:Gem::Requirement
|
182
|
-
requirements:
|
183
|
-
- - ">="
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '0'
|
186
|
-
type: :development
|
187
|
-
prerelease: false
|
188
|
-
version_requirements: !ruby/object:Gem::Requirement
|
189
|
-
requirements:
|
190
|
-
- - ">="
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
version: '0'
|
80
|
+
version: '1.8'
|
193
81
|
description:
|
194
82
|
email:
|
195
83
|
- jgrodowski@gmail.com
|
@@ -205,6 +93,7 @@ files:
|
|
205
93
|
- ".overcommit.yml"
|
206
94
|
- ".rspec"
|
207
95
|
- ".rubocop.yml"
|
96
|
+
- ".tool-versions"
|
208
97
|
- CHANGELOG.md
|
209
98
|
- Gemfile
|
210
99
|
- LICENSE.txt
|
@@ -240,14 +129,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
129
|
requirements:
|
241
130
|
- - ">="
|
242
131
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
132
|
+
version: 3.0.0
|
244
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
134
|
requirements:
|
246
135
|
- - ">="
|
247
136
|
- !ruby/object:Gem::Version
|
248
137
|
version: '0'
|
249
138
|
requirements: []
|
250
|
-
rubygems_version: 3.4
|
139
|
+
rubygems_version: 3.5.4
|
251
140
|
signing_key:
|
252
141
|
specification_version: 4
|
253
142
|
summary: Actionable code coverage - detects untested code blocks in recent changes
|