undercover 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +61 -0
- data/lib/undercover/cli.rb +15 -2
- data/lib/undercover/options.rb +12 -4
- data/lib/undercover/version.rb +1 -1
- data/lib/undercover.rb +12 -9
- data/undercover.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34741f7a74c75b9b6c91597b849a7d543864809b0dc8ec505f80d31fc7ed8ba2
|
4
|
+
data.tar.gz: 91a6589eac0676253c1c2c0ce3a8e0399c18cfd62b37e38aab06364397b1f4b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e2334be919b81fa7f186824da3a289cf4af15e875fb758aa93f1df1d7a1e8704082765a616a657c0f37efaa6d44640396cc8875ca9f39037902fe9ce5bb5f68
|
7
|
+
data.tar.gz: 4272d22c6e46532c552a1a9f01f815ee2a5be257bc951e04afdb34a9c4a812fdf7b609231c3ad2f2463f9e293bc46fc7a40d3e869a12a9edf8aa722899d85384
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.2.0] - 2018-08-19
|
10
|
+
### Added
|
11
|
+
- This `CHANGELOG.md`
|
12
|
+
- Ruby syntax version customisable with `-r` or `--ruby-syntax`
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Relative and absolute project path support
|
16
|
+
- typo in stale coverage warning message by @ilyakorol
|
17
|
+
|
18
|
+
## [0.1.7] - 2018-08-03
|
19
|
+
### Changed
|
20
|
+
- Readme updates by @westonganger.
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
- Handled invalid UTF-8 encoding errors from `parser`
|
24
|
+
|
25
|
+
## [0.1.6] - 2018-07-10
|
26
|
+
### Fixed
|
27
|
+
- Updated `imagen` to `0.1.3` which avoids a broken release of `parser`
|
28
|
+
|
29
|
+
## [0.1.5] - 2018-06-25
|
30
|
+
### Changed
|
31
|
+
- Avoided conflicts between `rainbow` and `pronto` versions for use in upcoming `pronto-undercover` gem
|
32
|
+
|
33
|
+
## [0.1.4] - 2018-05-20
|
34
|
+
### Fixed
|
35
|
+
- Quick fix 🤷♂️
|
36
|
+
|
37
|
+
## [0.1.3] - 2018-05-20
|
38
|
+
### Added
|
39
|
+
- `imagen` version bump adding block syntax support
|
40
|
+
|
41
|
+
## [0.1.2] - 2018-05-18
|
42
|
+
### Fixed
|
43
|
+
- `--version` cli option fix
|
44
|
+
|
45
|
+
## [0.1.1] - 2018-05-17
|
46
|
+
### Fixed
|
47
|
+
- CLI exit codes on success error
|
48
|
+
|
49
|
+
## [0.1.0] - 2018-05-10
|
50
|
+
### Added
|
51
|
+
- First release of `undercover` 🎉
|
52
|
+
|
53
|
+
[Unreleased]: https://github.com/grodowski/undercover/compare/v0.2.0...HEAD
|
54
|
+
[0.2.0]: https://github.com/grodowski/undercover/compare/v0.1.7...v0.2.0
|
55
|
+
[0.1.7]: https://github.com/grodowski/undercover/compare/v0.1.6...v0.1.7
|
56
|
+
[0.1.6]: https://github.com/grodowski/undercover/compare/v0.1.5...v0.1.6
|
57
|
+
[0.1.5]: https://github.com/grodowski/undercover/compare/v0.1.4...v0.1.5
|
58
|
+
[0.1.4]: https://github.com/grodowski/undercover/compare/v0.1.3...v0.1.4
|
59
|
+
[0.1.3]: https://github.com/grodowski/undercover/compare/v0.1.2...v0.1.3
|
60
|
+
[0.1.2]: https://github.com/grodowski/undercover/compare/v0.1.1...v0.1.2
|
61
|
+
[0.1.1]: https://github.com/grodowski/undercover/compare/v0.1.0...v0.1.1
|
data/lib/undercover/cli.rb
CHANGED
@@ -9,16 +9,18 @@ module Undercover
|
|
9
9
|
# traversing the whole project at first!
|
10
10
|
|
11
11
|
WARNINGS_TO_S = {
|
12
|
-
stale_coverage: Rainbow('♻️ Coverage data is older than your' \
|
12
|
+
stale_coverage: Rainbow('♻️ Coverage data is older than your ' \
|
13
13
|
'latest changes. Re-run tests to update').yellow,
|
14
14
|
no_changes: Rainbow('✅ No reportable changes').green
|
15
15
|
}.freeze
|
16
16
|
|
17
17
|
WARNINGS_TO_EXITCODE = {stale_coverage: 1, no_changes: 0}.freeze
|
18
18
|
|
19
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
19
20
|
def self.run(args)
|
20
21
|
opts = Undercover::Options.new.parse(args)
|
21
|
-
|
22
|
+
syntax_version(opts.syntax_version)
|
23
|
+
report = Undercover::Report.new(changeset(opts), opts).build
|
22
24
|
|
23
25
|
error = report.validate(opts.lcov)
|
24
26
|
if error
|
@@ -30,5 +32,16 @@ module Undercover
|
|
30
32
|
puts Undercover::Formatter.new(warnings)
|
31
33
|
warnings.any? ? 1 : 0
|
32
34
|
end
|
35
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
36
|
+
|
37
|
+
def self.syntax_version(version)
|
38
|
+
return unless version
|
39
|
+
Imagen.parser_version = version
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.changeset(opts)
|
43
|
+
git_dir = File.join(opts.path, opts.git_dir)
|
44
|
+
Undercover::Changeset.new(git_dir, opts.compare)
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
data/lib/undercover/options.rb
CHANGED
@@ -17,7 +17,7 @@ module Undercover
|
|
17
17
|
# OUTPUT_CIRCLEMATOR = :circlemator # posts warnings as review comments
|
18
18
|
].freeze
|
19
19
|
|
20
|
-
attr_accessor :lcov, :path, :git_dir, :compare
|
20
|
+
attr_accessor :lcov, :path, :git_dir, :compare, :syntax_version
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
# TODO: use run modes
|
@@ -29,7 +29,7 @@ module Undercover
|
|
29
29
|
self.git_dir = '.git'
|
30
30
|
end
|
31
31
|
|
32
|
-
# rubocop:disable Metrics/MethodLength
|
32
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
33
33
|
def parse(args)
|
34
34
|
OptionParser.new do |opts|
|
35
35
|
opts.banner = 'Usage: undercover [options]'
|
@@ -48,15 +48,15 @@ module Undercover
|
|
48
48
|
project_path_option(opts)
|
49
49
|
git_dir_option(opts)
|
50
50
|
compare_option(opts)
|
51
|
+
ruby_syntax_option(opts)
|
51
52
|
# TODO: parse dem other options and assign to self
|
52
53
|
# --quiet (skip progress bar)
|
53
54
|
# --exit-status (do not print report, just exit)
|
54
|
-
# --ruby-version (string, like '2.4.4', how to support in parser?)
|
55
55
|
end.parse(args)
|
56
56
|
guess_lcov_path unless lcov
|
57
57
|
self
|
58
58
|
end
|
59
|
-
# rubocop:enable Metrics/MethodLength
|
59
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
60
60
|
|
61
61
|
private
|
62
62
|
|
@@ -86,6 +86,14 @@ module Undercover
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
def ruby_syntax_option(parser)
|
90
|
+
versions = Imagen::AVAILABLE_RUBY_VERSIONS.sort.join(', ')
|
91
|
+
desc = "Ruby syntax version, one of: #{versions}"
|
92
|
+
parser.on('-r', '--ruby-synax ver', desc) do |version|
|
93
|
+
self.syntax_version = version.strip
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
89
97
|
def guess_lcov_path
|
90
98
|
cwd = Pathname.new(File.expand_path(path))
|
91
99
|
self.lcov = File.join(cwd, 'coverage', 'lcov', "#{cwd.split.last}.lcov")
|
data/lib/undercover/version.rb
CHANGED
data/lib/undercover.rb
CHANGED
@@ -26,18 +26,20 @@ module Undercover
|
|
26
26
|
|
27
27
|
# Initializes a new Undercover::Report
|
28
28
|
#
|
29
|
-
# @param
|
30
|
-
|
29
|
+
# @param changeset [Undercover::Changeset]
|
30
|
+
# @param opts [Undercover::Options]
|
31
|
+
def initialize(changeset, opts)
|
31
32
|
@lcov = LcovParser.parse(File.open(opts.lcov))
|
32
33
|
@code_dir = opts.path
|
33
|
-
|
34
|
-
@
|
35
|
-
@results = Hash.new { |hsh, key| hsh[key] = [] }
|
34
|
+
@changeset = changeset.update
|
35
|
+
@results = {}
|
36
36
|
end
|
37
37
|
|
38
38
|
def build
|
39
39
|
each_result_arg do |filename, coverage, imagen_node|
|
40
|
-
|
40
|
+
key = filename.gsub(/^\.\//, '')
|
41
|
+
results[key] ||= []
|
42
|
+
results[key] << Result.new(
|
41
43
|
imagen_node, coverage, filename
|
42
44
|
)
|
43
45
|
end
|
@@ -57,6 +59,7 @@ module Undercover
|
|
57
59
|
dist_from_line_no[res1] <=> dist_from_line_no[res2]
|
58
60
|
end
|
59
61
|
|
62
|
+
next unless results[filepath]
|
60
63
|
res = results[filepath].min(&dist_from_line_no_sorter)
|
61
64
|
flagged_results << res if res&.uncovered?(line_no)
|
62
65
|
end
|
@@ -80,12 +83,12 @@ module Undercover
|
|
80
83
|
# so is this still good idea? (Rakefile, .gemspec etc)
|
81
84
|
def each_result_arg
|
82
85
|
match_all = ->(_) { true }
|
83
|
-
lcov.source_files.each do |
|
84
|
-
path = File.join(code_dir,
|
86
|
+
lcov.source_files.each do |relative_filename, coverage|
|
87
|
+
path = File.join(code_dir, relative_filename)
|
85
88
|
root_ast = Imagen::Node::Root.new.build_from_file(path)
|
86
89
|
next if root_ast.children.empty?
|
87
90
|
root_ast.children[0].find_all(match_all).each do |node|
|
88
|
-
yield(
|
91
|
+
yield(relative_filename, coverage, node)
|
89
92
|
end
|
90
93
|
end
|
91
94
|
end
|
data/undercover.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency 'imagen', '~> 0.1.
|
26
|
+
spec.add_dependency 'imagen', '~> 0.1.5'
|
27
27
|
spec.add_dependency 'rainbow', '~> 2.1'
|
28
28
|
spec.add_dependency 'rugged', '~> 0.27.0'
|
29
29
|
|
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
|
+
version: 0.2.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: 2018-08-
|
11
|
+
date: 2018-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: imagen
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rainbow
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- ".rspec"
|
192
192
|
- ".rubocop.yml"
|
193
193
|
- ".travis.yml"
|
194
|
+
- CHANGELOG.md
|
194
195
|
- Gemfile
|
195
196
|
- LICENSE.txt
|
196
197
|
- README.md
|
@@ -227,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
228
|
version: '0'
|
228
229
|
requirements: []
|
229
230
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.6
|
231
|
+
rubygems_version: 2.7.6
|
231
232
|
signing_key:
|
232
233
|
specification_version: 4
|
233
234
|
summary: Actionable code coverage - detects untested code blocks in recent changes
|