pronto-undercover 0.1.0 → 0.1.5

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: 23a9e88cb350120dd32a0d30c92e6cf3dd5c015413c0ee3c16a700b6a4ada53d
4
- data.tar.gz: fa21ebfb5b108a702c33d4677e9dfa6d073123bce9f2f2c5181f3d6a03a72de9
3
+ metadata.gz: f08a3fece5d032981d425ef93209e29c3316f48ee07328206bab518e30d3b569
4
+ data.tar.gz: d285223a2379b7b3ae5e14f94a261a5bf882757c6c04b57a4a6ccd4fdf801cdd
5
5
  SHA512:
6
- metadata.gz: 868fd2ee69c581041f33be5adce989896df204bad5fb48a263b4938cb303dffc0e03064670eefb055729fcea6c0dc62e7ce3d9199f9f3a00a2b2dd36bbd12656
7
- data.tar.gz: fd26c906d8e29db5ba13962f2833e8aa30146d237a946c2b87882314a4dbae839be40c3ab7e7f21debf0907dd45eb8c2baf4bc9c4085f446c9c416d47f2f6228
6
+ metadata.gz: cf1d70766e0fa18715c3444798647a74d1bf5b26344b8efbe943b3c37e5c47e28e1b8bde93236c49c1d2f8232a93dd5fc920637a32f4dec667d49613e0012612
7
+ data.tar.gz: 462b2daee7ebadb872a76a1170f468134c939580a9fef7caff2d1f396253403b73d8cbce62074023e3d1cc973e9ab2285b3d20e0f56fd916acd22b1c5759e0fd
@@ -12,6 +12,10 @@ Layout/SpaceInsideHashLiteralBraces:
12
12
  Enabled: true
13
13
  EnforcedStyle: no_space
14
14
 
15
+ Metrics/LineLength:
16
+ Enabled: True
17
+ Max: 100
18
+
15
19
  Metrics/BlockLength:
16
20
  Enabled: true
17
21
  Exclude:
@@ -1,7 +1,12 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.5.1
5
- - 2.4.4
6
- - 2.3.4
7
- before_install: gem install bundler -v 1.16.2
3
+ - 2.7.1
4
+ - 2.6.6
5
+ - 2.5.8
6
+ before_install:
7
+ - gem install bundler undercover
8
+ - gem update --system
9
+ script:
10
+ - bundle exec rake
11
+ - git pull origin master:master
12
+ - undercover --compare master
@@ -0,0 +1,22 @@
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.1.5] - 2019-03-19
10
+ ### Added
11
+ - Use flagged_results accessor by @yassinecc
12
+
13
+ ## [0.1.4] - 2019-03-19
14
+ ### Added
15
+ - This `CHANGELOG.md`
16
+
17
+ ### Changed
18
+ - support `pronto >= 0.9`
19
+
20
+ [Unreleased]: https://github.com/grodowski/pronto-undercover/compare/v0.1.5...HEAD
21
+ [0.1.5]: https://github.com/grodowski/pronto-undercover/compare/v0.1.4...v0.1.5
22
+ [0.1.4]: https://github.com/grodowski/pronto-undercover/compare/v0.1.3...v0.1.4
@@ -17,6 +17,7 @@ module Pronto
17
17
  def last_modified
18
18
  mod = file_paths.map do |f|
19
19
  next T_ZERO unless File.exist?(f)
20
+
20
21
  File.mtime(f)
21
22
  end.max
22
23
  mod || T_ZERO
@@ -17,11 +17,12 @@ module Pronto
17
17
 
18
18
  # @return Array[Pronto::Message]
19
19
  def run
20
- return [] unless @patches.first
21
- report = ::Undercover::Report.new(
22
- @patch_changeset, undercover_options
23
- ).build
24
- report.build_warnings.map(&method(:undercover_warning_to_message))
20
+ return [] if !@patches || @patches.count.zero?
21
+
22
+ @patches
23
+ .select { |patch| valid_patch?(patch) }
24
+ .map { |patch| patch_to_undercover_message(patch) }
25
+ .flatten.compact
25
26
  rescue Errno::ENOENT => e
26
27
  warn("Could not open file! #{e}")
27
28
  []
@@ -29,20 +30,44 @@ module Pronto
29
30
 
30
31
  private
31
32
 
32
- # rubocop:disable Metrics/AbcSize
33
- def undercover_warning_to_message(warning)
34
- lines = untested_lines_for(warning)
35
- msg = "#{warning.node.human_name} #{warning.node.name} missing tests" \
36
- " for line#{'s' if lines.size > 1} #{lines.join(', ')}" \
37
- " (coverage: #{warning.coverage_f})"
38
-
39
- line = @patches.find_line(
40
- Pathname.new(File.expand_path(warning.file_path)),
41
- warning.first_line
42
- )
43
- Message.new(warning.file_path, line, DEFAULT_LEVEL, msg)
33
+ def valid_patch?(patch)
34
+ patch.additions.positive? && ruby_file?(patch.new_file_full_path)
35
+ end
36
+
37
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
38
+ def patch_to_undercover_message(patch)
39
+ offending_line_numbers(patch).map do |warning, msg_line_no|
40
+ patch
41
+ .added_lines
42
+ .select { |line| line.new_lineno == msg_line_no }
43
+ .map do |line|
44
+ lines = untested_lines_for(warning)
45
+ path = line.patch.delta.new_file[:path]
46
+ msg = "#{warning.node.human_name} #{warning.node.name} missing tests" \
47
+ " for line#{'s' if lines.size > 1} #{lines.join(', ')}" \
48
+ " (coverage: #{warning.coverage_f})"
49
+ Message.new(path, line, DEFAULT_LEVEL, msg, nil, self.class)
50
+ end
51
+ end
52
+ end
53
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
54
+
55
+ def undercover_warnings
56
+ @undercover_warnings ||= ::Undercover::Report.new(
57
+ @patch_changeset, undercover_options
58
+ ).build.flagged_results
59
+ end
60
+
61
+ def offending_line_numbers(patch)
62
+ patch_lines = patch.added_lines.map(&:new_lineno)
63
+ path = patch.new_file_full_path.to_s
64
+ undercover_warnings
65
+ .select { |warning| File.expand_path(warning.file_path) == path }
66
+ .map do |warning|
67
+ first_line_no = patch_lines.find { |l| warning.uncovered?(l) }
68
+ [warning, first_line_no] if first_line_no
69
+ end.compact
44
70
  end
45
- # rubocop:enable Metrics/AbcSize
46
71
 
47
72
  def untested_lines_for(warning)
48
73
  warning.coverage.map do |ln, _cov|
@@ -50,13 +75,17 @@ module Pronto
50
75
  end.compact
51
76
  end
52
77
 
78
+ # rubocop:disable Metrics/AbcSize
53
79
  def undercover_options
54
- config = Pronto::ConfigFile.new.to_h
80
+ config = Pronto::ConfigFile.new.to_h['pronto-undercover']
81
+ return ::Undercover::Options.new.parse([]) unless config
82
+
55
83
  opts = []
56
84
  opts << "-l#{config['lcov']}" if config['lcov']
57
85
  opts << "-r#{config['ruby-syntax']}" if config['ruby-syntax']
58
86
  opts << "-p#{config['path']}" if config['path']
59
87
  ::Undercover::Options.new.parse(opts)
60
88
  end
89
+ # rubocop:enable Metrics/AbcSize
61
90
  end
62
91
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pronto
4
4
  module UndercoverVersion
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.5'
6
6
  end
7
7
  end
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  end
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'pronto', '~> 0.9.0'
23
- spec.add_dependency 'undercover', '~> 0.2.0'
22
+ spec.add_dependency 'pronto', '>= 0.9', '< 0.11'
23
+ spec.add_dependency 'undercover', '~> 0.3.4'
24
24
  spec.add_development_dependency 'pry'
25
- spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
27
  spec.add_development_dependency 'rubocop'
28
28
  spec.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-undercover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
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-09-07 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 0.9.0
22
+ version: '0.11'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 0.9.0
32
+ version: '0.11'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: undercover
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 0.2.0
39
+ version: 0.3.4
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 0.2.0
46
+ version: 0.3.4
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: pry
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +64,14 @@ dependencies:
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '10.0'
67
+ version: '13.0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '10.0'
74
+ version: '13.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rspec
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -161,6 +167,7 @@ files:
161
167
  - ".rspec"
162
168
  - ".rubocop.yml"
163
169
  - ".travis.yml"
170
+ - CHANGELOG.md
164
171
  - Gemfile
165
172
  - LICENSE.txt
166
173
  - README.md
@@ -188,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
195
  - !ruby/object:Gem::Version
189
196
  version: '0'
190
197
  requirements: []
191
- rubyforge_project:
192
- rubygems_version: 2.7.6
198
+ rubygems_version: 3.1.2
193
199
  signing_key:
194
200
  specification_version: 4
195
201
  summary: Pronto runner for Undercover - actionable code coverage