undercover 0.3.3 → 0.3.4
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 +3 -3
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +7 -1
- data/LICENSE.txt +1 -1
- data/bin/undercover +1 -0
- data/docs/codeship.md +1 -1
- data/docs/travis.yml +1 -1
- data/lib/undercover.rb +41 -33
- data/lib/undercover/cli.rb +3 -3
- data/lib/undercover/lcov_parser.rb +7 -0
- data/lib/undercover/result.rb +10 -1
- data/lib/undercover/version.rb +1 -1
- data/undercover.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 876068f41c32798bbc3e6d2e37980021c5afebf2d7316700671741b64e4959ae
|
4
|
+
data.tar.gz: 55fea89d18b7e6feeac2821f97a008999c2442aac83b53239c353fb05d6875f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1210f2973aee4c7bea1484c9eef36dce6bf8582eec0f9f95a94585bdc03cce9df7e5f8d750f33d2838f0329fd466e636fba7f05d2080c998717048a09520172f
|
7
|
+
data.tar.gz: 0cc9be1fa5e3fe60009b71a9b2212c24f2f3c7f20a8df674821dcbd2c2ca5e1157dc04ece674b221d8bbbcaab3f4cfb6084846241474d664e98b644484e77e08
|
data/.github/workflows/ruby.yml
CHANGED
@@ -4,8 +4,8 @@ jobs:
|
|
4
4
|
build:
|
5
5
|
runs-on: ubuntu-latest
|
6
6
|
strategy:
|
7
|
-
matrix:
|
8
|
-
ruby: ['2.
|
7
|
+
matrix:
|
8
|
+
ruby: ['2.7.x', '2.6.x', '2.5.x']
|
9
9
|
steps:
|
10
10
|
- uses: actions/checkout@v1
|
11
11
|
- name: Set up Ruby ${{ matrix.ruby }}
|
@@ -17,5 +17,5 @@ jobs:
|
|
17
17
|
gem install bundler undercover --no-doc
|
18
18
|
bundle install --jobs 4 --retry 3
|
19
19
|
bundle exec rake
|
20
|
-
git
|
20
|
+
git fetch origin master:master
|
21
21
|
undercover --compare master
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.7.0
|
3
3
|
Exclude:
|
4
4
|
- spec/fixtures/**/*
|
5
5
|
|
@@ -21,3 +21,12 @@ Metrics/BlockLength:
|
|
21
21
|
Enabled: true
|
22
22
|
Exclude:
|
23
23
|
- spec/**/*
|
24
|
+
|
25
|
+
Style/HashEachMethods:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Style/HashTransformKeys:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
Style/HashTransformValues:
|
32
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.3.4] - 2020-04-05
|
10
|
+
### Changed
|
11
|
+
- Updated parsing performance by scoping `all_results` to git diff
|
12
|
+
- Dependecy updates
|
13
|
+
|
9
14
|
## [0.3.3] - 2019-12-29
|
10
15
|
### Fixed
|
11
16
|
- `.gemspec` requires `imagen >= 0.1.8` to address compatibility issues
|
@@ -81,7 +86,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
81
86
|
### Added
|
82
87
|
- First release of `undercover` 🎉
|
83
88
|
|
84
|
-
[Unreleased]: https://github.com/grodowski/undercover/compare/v0.3.
|
89
|
+
[Unreleased]: https://github.com/grodowski/undercover/compare/v0.3.4...HEAD
|
90
|
+
[0.3.4]: https://github.com/grodowski/undercover/compare/v0.3.3...v0.3.4
|
85
91
|
[0.3.3]: https://github.com/grodowski/undercover/compare/v0.3.2...v0.3.3
|
86
92
|
[0.3.2]: https://github.com/grodowski/undercover/compare/v0.3.1...v0.3.2
|
87
93
|
[0.3.1]: https://github.com/grodowski/undercover/compare/v0.3.0...v0.3.1
|
data/LICENSE.txt
CHANGED
data/bin/undercover
CHANGED
data/docs/codeship.md
CHANGED
@@ -12,7 +12,7 @@ gem install undercover
|
|
12
12
|
|
13
13
|
```
|
14
14
|
bundle exec rspec --format documentation --color
|
15
|
-
#
|
15
|
+
# fetch origin/master to have a ref to compare against
|
16
16
|
git remote set-branches --add origin master
|
17
17
|
git fetch
|
18
18
|
undercover -c origin/master
|
data/docs/travis.yml
CHANGED
data/lib/undercover.rb
CHANGED
@@ -32,25 +32,12 @@ module Undercover
|
|
32
32
|
@lcov = LcovParser.parse(File.open(opts.lcov))
|
33
33
|
@code_dir = opts.path
|
34
34
|
@changeset = changeset.update
|
35
|
+
@loaded_files = {}
|
35
36
|
@results = {}
|
36
37
|
end
|
37
38
|
|
38
|
-
def build
|
39
|
-
each_result_arg do |filename, coverage, imagen_node|
|
40
|
-
key = filename.gsub(/^\.\//, '')
|
41
|
-
results[key] ||= []
|
42
|
-
results[key] << Result.new(
|
43
|
-
imagen_node, coverage, filename
|
44
|
-
)
|
45
|
-
end
|
46
|
-
self
|
47
|
-
end
|
48
|
-
|
49
|
-
# TODO: this is experimental and might be incorrect!
|
50
39
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
51
|
-
def
|
52
|
-
flagged_results = Set.new
|
53
|
-
|
40
|
+
def build
|
54
41
|
changeset.each_changed_line do |filepath, line_no|
|
55
42
|
dist_from_line_no = lambda do |res|
|
56
43
|
return BigDecimal::INFINITY if line_no < res.first_line
|
@@ -63,17 +50,31 @@ module Undercover
|
|
63
50
|
dist_from_line_no_sorter = lambda do |res1, res2|
|
64
51
|
dist_from_line_no[res1] <=> dist_from_line_no[res2]
|
65
52
|
end
|
66
|
-
|
53
|
+
load_and_parse_file(filepath)
|
67
54
|
|
68
|
-
|
69
|
-
|
55
|
+
next unless loaded_files[filepath]
|
56
|
+
|
57
|
+
res = loaded_files[filepath].min(&dist_from_line_no_sorter)
|
58
|
+
res.flag if res&.uncovered?(line_no)
|
59
|
+
results[filepath] ||= Set.new
|
60
|
+
results[filepath] << res
|
70
61
|
end
|
71
|
-
|
62
|
+
self
|
72
63
|
end
|
73
64
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
74
65
|
|
66
|
+
def build_warnings
|
67
|
+
warn('Undercover::Report#build_warnings is deprecated! ' \
|
68
|
+
'Please use the #flagged_results accessor instead.')
|
69
|
+
all_results.select(&:flagged?)
|
70
|
+
end
|
71
|
+
|
75
72
|
def all_results
|
76
|
-
results.values.flatten
|
73
|
+
results.values.map(&:to_a).flatten
|
74
|
+
end
|
75
|
+
|
76
|
+
def flagged_results
|
77
|
+
all_results.select(&:flagged?)
|
77
78
|
end
|
78
79
|
|
79
80
|
def inspect
|
@@ -83,20 +84,27 @@ module Undercover
|
|
83
84
|
|
84
85
|
private
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
#
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
87
|
+
attr_reader :loaded_files
|
88
|
+
|
89
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
90
|
+
def load_and_parse_file(filepath)
|
91
|
+
key = filepath.gsub(/^\.\//, '')
|
92
|
+
return if loaded_files[key]
|
93
|
+
|
94
|
+
coverage = lcov.coverage(filepath)
|
95
|
+
return if coverage.empty?
|
96
|
+
|
97
|
+
root_ast = Imagen::Node::Root.new.build_from_file(
|
98
|
+
File.join(code_dir, filepath)
|
99
|
+
)
|
100
|
+
return if root_ast.children.empty?
|
101
|
+
|
102
|
+
loaded_files[key] = []
|
103
|
+
# TODO: children[0] ignores the lonely_method (see spec fixtures)!
|
104
|
+
root_ast.children[0].find_all(->(_) { true }).each do |imagen_node|
|
105
|
+
loaded_files[key] << Result.new(imagen_node, coverage, filepath)
|
99
106
|
end
|
100
107
|
end
|
108
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
101
109
|
end
|
102
110
|
end
|
data/lib/undercover/cli.rb
CHANGED
@@ -31,9 +31,9 @@ module Undercover
|
|
31
31
|
return 0 if error == :no_changes
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
puts Undercover::Formatter.new(
|
36
|
-
|
34
|
+
flagged = report.flagged_results
|
35
|
+
puts Undercover::Formatter.new(flagged)
|
36
|
+
flagged.any? ? 1 : 0
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.syntax_version(version)
|
@@ -22,6 +22,13 @@ module Undercover
|
|
22
22
|
self
|
23
23
|
end
|
24
24
|
|
25
|
+
def coverage(filepath)
|
26
|
+
_filename, coverage = source_files.find do |relative_path, _|
|
27
|
+
relative_path == filepath
|
28
|
+
end
|
29
|
+
coverage || []
|
30
|
+
end
|
31
|
+
|
25
32
|
private
|
26
33
|
|
27
34
|
# rubocop:disable Metrics/MethodLength, Style/SpecialGlobalVars
|
data/lib/undercover/result.rb
CHANGED
@@ -8,7 +8,7 @@ module Undercover
|
|
8
8
|
|
9
9
|
attr_reader :node, :coverage, :file_path
|
10
10
|
|
11
|
-
def_delegators :node, :first_line, :last_line
|
11
|
+
def_delegators :node, :first_line, :last_line, :name
|
12
12
|
|
13
13
|
def initialize(node, file_cov, file_path)
|
14
14
|
@node = node
|
@@ -16,6 +16,15 @@ module Undercover
|
|
16
16
|
ln > first_line && ln < last_line
|
17
17
|
end
|
18
18
|
@file_path = file_path
|
19
|
+
@flagged = false
|
20
|
+
end
|
21
|
+
|
22
|
+
def flag
|
23
|
+
@flagged = true
|
24
|
+
end
|
25
|
+
|
26
|
+
def flagged?
|
27
|
+
@flagged
|
19
28
|
end
|
20
29
|
|
21
30
|
# TODO: make DRY
|
data/lib/undercover/version.rb
CHANGED
data/undercover.gemspec
CHANGED
@@ -25,13 +25,13 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_dependency 'imagen', '>= 0.1.8'
|
27
27
|
spec.add_dependency 'rainbow', '>= 2.1', '< 4.0'
|
28
|
-
spec.add_dependency 'rugged', '>= 0.27', '<
|
28
|
+
spec.add_dependency 'rugged', '>= 0.27', '< 1.1'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler'
|
31
31
|
spec.add_development_dependency 'pry'
|
32
32
|
spec.add_development_dependency 'rake', '~> 13.0'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 0.81.0'
|
35
35
|
spec.add_development_dependency 'simplecov'
|
36
36
|
spec.add_development_dependency 'simplecov-html'
|
37
37
|
spec.add_development_dependency 'simplecov-lcov'
|
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.3.
|
4
|
+
version: 0.3.4
|
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: 2020-04-05 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: '
|
56
|
+
version: '1.1'
|
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: '
|
66
|
+
version: '1.1'
|
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: 0.
|
129
|
+
version: 0.81.0
|
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: 0.
|
136
|
+
version: 0.81.0
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
name: simplecov
|
139
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
245
|
- !ruby/object:Gem::Version
|
246
246
|
version: '0'
|
247
247
|
requirements: []
|
248
|
-
rubygems_version: 3.
|
248
|
+
rubygems_version: 3.1.2
|
249
249
|
signing_key:
|
250
250
|
specification_version: 4
|
251
251
|
summary: Actionable code coverage - detects untested code blocks in recent changes
|