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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ad060fa8459db10f25f0b6d7591c8e15a7aa64aa8f13d6f6fe1e035ef1b6c90
4
- data.tar.gz: e73ddbb578d770a7bed01f01e30688cfd3c6da7d9d204a5f2b4136d77e8e5f5d
3
+ metadata.gz: 876068f41c32798bbc3e6d2e37980021c5afebf2d7316700671741b64e4959ae
4
+ data.tar.gz: 55fea89d18b7e6feeac2821f97a008999c2442aac83b53239c353fb05d6875f2
5
5
  SHA512:
6
- metadata.gz: 369e92ed7a0a55ac723a56a6b753529350fb97a9afa4454ae147320b659ca800c96bc88d5e2a39029c45b0632d4b42356f8d73105319410468a1057cbd190f42
7
- data.tar.gz: '09987aa4687852f590257a3297c19b5e159f140cd0d97d1c8ffb6b6eeb11a645617e10281d596d802401e9e83550058f26b502571637ec9ed370a4f5530d39ed'
6
+ metadata.gz: 1210f2973aee4c7bea1484c9eef36dce6bf8582eec0f9f95a94585bdc03cce9df7e5f8d750f33d2838f0329fd466e636fba7f05d2080c998717048a09520172f
7
+ data.tar.gz: 0cc9be1fa5e3fe60009b71a9b2212c24f2f3c7f20a8df674821dcbd2c2ca5e1157dc04ece674b221d8bbbcaab3f4cfb6084846241474d664e98b644484e77e08
@@ -4,8 +4,8 @@ jobs:
4
4
  build:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
- matrix:
8
- ruby: ['2.6.x', '2.5.x', '2.4.x']
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 pull origin master:master
20
+ git fetch origin master:master
21
21
  undercover --compare master
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4.4
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
@@ -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.3...HEAD
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Jan Grodowski
3
+ Copyright (c) 2018-2020 Jan Grodowski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  $LOAD_PATH.unshift("#{__dir__}/../lib")
5
+ $VERBOSE = nil
5
6
 
6
7
  require 'undercover'
7
8
  require 'benchmark'
@@ -12,7 +12,7 @@ gem install undercover
12
12
 
13
13
  ```
14
14
  bundle exec rspec --format documentation --color
15
- # pull origin/master to have a ref to compare against
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
@@ -9,5 +9,5 @@ before_install:
9
9
  - gem update --system
10
10
  script:
11
11
  - bundle exec rake
12
- - git pull origin master:master
12
+ - git fetch origin master:master
13
13
  - undercover --compare master
@@ -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 build_warnings
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
- next unless results[filepath]
53
+ load_and_parse_file(filepath)
67
54
 
68
- res = results[filepath].min(&dist_from_line_no_sorter)
69
- flagged_results << res if res&.uncovered?(line_no)
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
- flagged_results
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
- # TODO: should that start from changeset.file_paths?
87
- # this way we could report things that weren't even loaded in any spec,
88
- # so is this still good idea? (Rakefile, .gemspec etc)
89
- def each_result_arg
90
- match_all = ->(_) { true }
91
- lcov.source_files.each do |relative_filename, coverage|
92
- path = File.join(code_dir, relative_filename)
93
- root_ast = Imagen::Node::Root.new.build_from_file(path)
94
- next if root_ast.children.empty?
95
-
96
- root_ast.children[0].find_all(match_all).each do |node|
97
- yield(relative_filename, coverage, node)
98
- end
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
@@ -31,9 +31,9 @@ module Undercover
31
31
  return 0 if error == :no_changes
32
32
  end
33
33
 
34
- warnings = report.build_warnings
35
- puts Undercover::Formatter.new(warnings)
36
- warnings.any? ? 1 : 0
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Undercover
4
- VERSION = '0.3.3'
4
+ VERSION = '0.3.4'
5
5
  end
@@ -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', '< 0.29'
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.78.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.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: 2019-12-29 00:00:00.000000000 Z
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: '0.29'
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: '0.29'
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.78.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.78.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.0.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