undercover 0.4.4 → 0.4.6

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: f6cd3608abfe38ef691799586ac21e0818846ea2b67e7867af9c917762c28de7
4
- data.tar.gz: 434a7428414fe21d31e5cf691255f39f5abdc9a0e370f39a362d7ac6f90ae7a4
3
+ metadata.gz: bff312e0fdc1d61bc1ac46a49812fe490bc57d095f660ba38df00686b1d08a28
4
+ data.tar.gz: b8df1a289dd957868632ecb1aea06033b6945e75357163f1007136ccae94d9b3
5
5
  SHA512:
6
- metadata.gz: 18574633620761accff515e582f79949c7bd4deaae9f5e44dfdba03cddfeed39c76d271214be0bbccf6c51da1c0231bd290693679cfd182753b14102bc4dac0b
7
- data.tar.gz: 05f18a34ffa46f66a4cb73c9143c0851e295ad60129e7969d2e72a6350af5a874713201797f75ff8bbcaebfe27918a322b75e3b5eb9508eb20140ca5ad82d0bf
6
+ metadata.gz: b4fee8956df8fd10483e7c6af403859c1e93775fe8d322b3709f22d38b14cbcd4139aea072692eb5bb754f1d581ebf7123352b63d5641c0f7810ee9ba3a577a2
7
+ data.tar.gz: 1dfced71df7fb571add736bb31877ae5c3116796c3c3a888db9e3e1d6f8c7ad92809f47dce700ead01064299706a6edf0347d8333ba8218ec8696512de5ca854
@@ -5,11 +5,11 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
7
  matrix:
8
- ruby: ['3.0.x', '2.7.x', '2.6.x', '2.5.x']
8
+ ruby: ['3.2', '3.0', '2.7']
9
9
  steps:
10
10
  - uses: actions/checkout@v1
11
11
  - name: Set up Ruby ${{ matrix.ruby }}
12
- uses: actions/setup-ruby@v1
12
+ uses: ruby/setup-ruby@v1
13
13
  with:
14
14
  ruby-version: ${{ matrix.ruby }}
15
15
  - name: Build and test with Rake
@@ -17,5 +17,24 @@ jobs:
17
17
  gem install bundler undercover --no-doc
18
18
  bundle install --jobs 4 --retry 3
19
19
  bundle exec rake
20
+ - name: undercover (local)
21
+ run: |
20
22
  git fetch origin master:master
21
23
  undercover --compare master
24
+ - uses: actions/upload-artifact@v2
25
+ with:
26
+ name: undercover.lcov
27
+ path: coverage/lcov/undercover.lcov
28
+ coverage:
29
+ runs-on: ubuntu-latest
30
+ needs: build
31
+ steps:
32
+ - uses: actions/download-artifact@v2
33
+ with:
34
+ name: undercover.lcov
35
+ - name: Upload coverage
36
+ run: |
37
+ ruby -e "$(curl -s https://undercover-ci.com/uploader.rb)" -- \
38
+ --repo grodowski/undercover \
39
+ --commit $GITHUB_SHA \
40
+ --lcov /home/runner/work/undercover/undercover/undercover.lcov
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
- TargetRubyVersion: 2.5.0
3
+ TargetRubyVersion: 2.7.0
4
4
  Exclude:
5
5
  - spec/fixtures/**/*
6
6
 
data/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Changed
10
+ - Drop support for ruby < 2.7
11
+
12
+ # [0.4.5] - 2022-07-28
13
+ ### Changed
14
+ - Update `rugged` dependency to `< 1.6`
15
+
9
16
  # [0.4.4] - 2021-11-29
10
17
  ### Changed
11
18
  - Dependency updates
@@ -108,7 +115,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
108
115
  - First release of `undercover` 🎉
109
116
 
110
117
  [Unreleased]: https://github.com/grodowski/undercover/compare/v0.4.4...HEAD
111
- [0.4.3]: https://github.com/grodowski/undercover/compare/v0.4.3...v0.4.4
118
+ [0.4.5]: https://github.com/grodowski/undercover/compare/v0.4.4...v0.4.5
119
+ [0.4.4]: https://github.com/grodowski/undercover/compare/v0.4.3...v0.4.4
112
120
  [0.4.3]: https://github.com/grodowski/undercover/compare/v0.4.1...v0.4.3
113
121
  [0.4.1]: https://github.com/grodowski/undercover/compare/v0.4.0...v0.4.1
114
122
  [0.4.0]: https://github.com/grodowski/undercover/compare/v0.3.4...v0.4.0
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # undercover 👮‍♂️
2
2
 
3
- **Like RuboCop but for code coverage**. Inspects files in a git diff and warns on changed methods, classes and blocks which need to be tested. Use it locally or as part of an automated build to shorten your code coverage feedback loop!
3
+ [![Build Status](https://github.com/grodowski/undercover/actions/workflows/ruby.yml/badge.svg)](https://github.com/grodowski/undercover/actions)
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)
6
+
7
+ `undercover` examines git diffs and warns about Ruby methods, classes and blocks that **were changed without sufficient test coverage**.
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.
4
10
 
5
- - Visit **[https://undercover-ci.com](https://undercover-ci.com)** to set up actionable GitHub code review checks, or use one of the [integrations](#code-review-integrations)
11
+ - 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)
6
12
  - Learn how to find untested code changes locally with the [CLI](#usage)
7
13
 
8
14
  A sample output of `undercover` ran before a commit may look like this:
@@ -13,9 +19,6 @@ And like this, given that specs were added:
13
19
 
14
20
  ![screenshot success](docs/screenshot_success.png)
15
21
 
16
- [![Build Status](https://action-badges.now.sh/grodowski/undercover)](https://github.com/grodowski/undercover/actions)
17
- [![Maintainability](https://api.codeclimate.com/v1/badges/b403feed68a18c072ec5/maintainability)](https://codeclimate.com/github/grodowski/undercover/maintainability)
18
-
19
22
  ## Installation
20
23
 
21
24
  Add this line to your application's Gemfile:
@@ -124,6 +127,22 @@ The options set in the file can be overriden by passing arguments when invoking
124
127
 
125
128
  Options assume that the program is run from the top level of the project directory.
126
129
 
130
+ ### Ignoring/skipping coverage
131
+
132
+ Projects with low or nonexistent test coverage are likely to generate large numbers of warnings. While the default workflow would be to address them before the PR approval, your strategy might be different.
133
+
134
+ In order to acknowledge an untested change and remove the UndercoverCI warning with the intention to improve later (or never), you can wrap the code block with the `:nocov:` syntax, e.g.
135
+
136
+ ```rb
137
+ # :nocov:
138
+ def skip_this_method
139
+ never_reached
140
+ end
141
+ # :nocov:
142
+ ```
143
+
144
+ Read more about the `:nocov:` syntax in [SimpleCov's readme](https://github.com/simplecov-ruby/simplecov#ignoringskipping-code).
145
+
127
146
  ## Why?
128
147
 
129
148
  I wanted to create a tool to help others and myself ensure that tests are written for all the recent code changes. This should be useful for any ruby project, but especially those large or legacy codebases that lack testing (and we can't or don't want to invest in full test coverage).
@@ -29,6 +29,24 @@ module Undercover
29
29
  coverage || []
30
30
  end
31
31
 
32
+ def total_coverage
33
+ all_lines = source_files.values.flatten(1)
34
+ return 0 if all_lines.empty?
35
+
36
+ all_lines = all_lines.select { _1.size == 2 }
37
+ total_f = all_lines.select { |_line_no, hits| hits.positive? }.size.to_f / all_lines.size
38
+ total_f.round(3)
39
+ end
40
+
41
+ def total_branch_coverage
42
+ all_lines = source_files.values.flatten(1)
43
+ return 0 if all_lines.empty?
44
+
45
+ all_branches = all_lines.select { _1.size == 4 }
46
+ total_f = all_branches.select { |_l_no, _block_no, _br_no, hits| hits.positive? }.size.to_f / all_branches.size
47
+ total_f.round(3)
48
+ end
49
+
32
50
  private
33
51
 
34
52
  # rubocop:disable Metrics/MethodLength, Style/SpecialGlobalVars, Metrics/AbcSize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Undercover
4
- VERSION = '0.4.4'
4
+ VERSION = '0.4.6'
5
5
  end
data/undercover.gemspec CHANGED
@@ -15,25 +15,28 @@ Gem::Specification.new do |spec|
15
15
  ' code blocks in recent changes'
16
16
  spec.homepage = 'https://github.com/grodowski/undercover'
17
17
  spec.license = 'MIT'
18
+ spec.metadata = {
19
+ 'rubygems_mfa_required' => 'true'
20
+ }
18
21
 
19
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
23
  f.match(/^(test|spec|features)\//)
21
24
  end
22
25
  spec.bindir = 'bin'
23
26
  spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
24
27
  spec.require_paths = ['lib']
25
28
 
26
- spec.required_ruby_version = '>= 2.5.0'
29
+ spec.required_ruby_version = '>= 2.7.0'
27
30
 
28
31
  spec.add_dependency 'imagen', '>= 0.1.8'
29
32
  spec.add_dependency 'rainbow', '>= 2.1', '< 4.0'
30
- spec.add_dependency 'rugged', '>= 0.27', '< 1.3'
33
+ spec.add_dependency 'rugged', '>= 0.27', '< 1.7'
31
34
 
32
35
  spec.add_development_dependency 'bundler'
33
36
  spec.add_development_dependency 'pry'
34
37
  spec.add_development_dependency 'rake', '~> 13.0'
35
38
  spec.add_development_dependency 'rspec', '~> 3.0'
36
- spec.add_development_dependency 'rubocop', '~> 1.22.1'
39
+ spec.add_development_dependency 'rubocop', '~> 1.28.2'
37
40
  spec.add_development_dependency 'simplecov'
38
41
  spec.add_development_dependency 'simplecov-html'
39
42
  spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undercover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Grodowski
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2023-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: imagen
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '0.27'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '1.3'
56
+ version: '1.7'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ dependencies:
63
63
  version: '0.27'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '1.3'
66
+ version: '1.7'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: bundler
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -126,14 +126,14 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: 1.22.1
129
+ version: 1.28.2
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: 1.22.1
136
+ version: 1.28.2
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: simplecov
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +190,7 @@ dependencies:
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
- description:
193
+ description:
194
194
  email:
195
195
  - jgrodowski@gmail.com
196
196
  executables:
@@ -230,8 +230,9 @@ files:
230
230
  homepage: https://github.com/grodowski/undercover
231
231
  licenses:
232
232
  - MIT
233
- metadata: {}
234
- post_install_message:
233
+ metadata:
234
+ rubygems_mfa_required: 'true'
235
+ post_install_message:
235
236
  rdoc_options: []
236
237
  require_paths:
237
238
  - lib
@@ -239,15 +240,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
240
  requirements:
240
241
  - - ">="
241
242
  - !ruby/object:Gem::Version
242
- version: 2.5.0
243
+ version: 2.7.0
243
244
  required_rubygems_version: !ruby/object:Gem::Requirement
244
245
  requirements:
245
246
  - - ">="
246
247
  - !ruby/object:Gem::Version
247
248
  version: '0'
248
249
  requirements: []
249
- rubygems_version: 3.2.22
250
- signing_key:
250
+ rubygems_version: 3.4.1
251
+ signing_key:
251
252
  specification_version: 4
252
253
  summary: Actionable code coverage - detects untested code blocks in recent changes
253
254
  test_files: []