pronto-undercover 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 23a9e88cb350120dd32a0d30c92e6cf3dd5c015413c0ee3c16a700b6a4ada53d
4
+ data.tar.gz: fa21ebfb5b108a702c33d4677e9dfa6d073123bce9f2f2c5181f3d6a03a72de9
5
+ SHA512:
6
+ metadata.gz: 868fd2ee69c581041f33be5adce989896df204bad5fb48a263b4938cb303dffc0e03064670eefb055729fcea6c0dc62e7ce3d9199f9f3a00a2b2dd36bbd12656
7
+ data.tar.gz: fd26c906d8e29db5ba13962f2833e8aa30146d237a946c2b87882314a4dbae839be40c3ab7e7f21debf0907dd45eb8c2baf4bc9c4085f446c9c416d47f2f6228
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ Gemfile.lock
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ .rbenv-gemsets
16
+ .ruby-version
17
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4.4
3
+
4
+ Style/RegexpLiteral:
5
+ EnforcedStyle: slashes
6
+ AllowInnerSlashes: true
7
+
8
+ Style/Documentation:
9
+ Enabled: false
10
+
11
+ Layout/SpaceInsideHashLiteralBraces:
12
+ Enabled: true
13
+ EnforcedStyle: no_space
14
+
15
+ Metrics/BlockLength:
16
+ Enabled: true
17
+ Exclude:
18
+ - spec/**/*
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ - 2.4.4
6
+ - 2.3.4
7
+ before_install: gem install bundler -v 1.16.2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in pronto-undercover.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jan Grodowski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ [![Build Status](https://travis-ci.org/grodowski/pronto-undercover.svg?branch=master)](https://travis-ci.org/grodowski/pronto-undercover)
2
+
3
+ # Pronto::Undercover
4
+
5
+ Pronto runner for [Undercover](https://github.com/grodowski/undercover), an actionable code coverage tool. What is [Pronto](https://github.com/prontolabs/pronto)?
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile
10
+
11
+ ```ruby
12
+ gem 'pronto-undercover'
13
+ ```
14
+
15
+ or install the gem with
16
+
17
+ ```shell
18
+ gem install pronto-undercover
19
+ ```
20
+
21
+ Once installed, `pronto run` will include undercover warnings. You can verify the install by running `pronto list`.
22
+
23
+ ## Configuring
24
+
25
+ `pronto-undercover` stores options passed to undercover in `.pronto.yml`. Please note that `--git-dir` and `--compare` options are not available, because `pronto-undercover` uses `Pronto::Git` instead of undercover's implementation.
26
+
27
+ Available options:
28
+
29
+ ```
30
+ # .pronto.yml
31
+ # ...other configuration
32
+ pronto-undercover:
33
+ path: path/to/project
34
+ lcov: path/to/project/coverage/report.lcov
35
+ ruby-syntax: ruby19
36
+ ```
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RuboCop::RakeTask.new(:rubocop)
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: %i[rubocop spec]
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pronto
4
+ # Quacks like Undercover::Changeset but wraps Pronto::Patches
5
+ # to provide full compatibility with pronto's git diff options
6
+ class PatchChangeset
7
+ T_ZERO = Time.strptime('0', '%s').freeze
8
+
9
+ def initialize(patches)
10
+ @patches = patches
11
+ end
12
+
13
+ def update
14
+ self # no-op for this class
15
+ end
16
+
17
+ def last_modified
18
+ mod = file_paths.map do |f|
19
+ next T_ZERO unless File.exist?(f)
20
+ File.mtime(f)
21
+ end.max
22
+ mod || T_ZERO
23
+ end
24
+
25
+ def file_paths
26
+ @patches.map(&:new_file_full_path)
27
+ end
28
+
29
+ def each_changed_line
30
+ @patches.each do |patch|
31
+ patch.added_lines.each do |line|
32
+ yield patch.delta.new_file[:path].to_s, line.new_lineno
33
+ end
34
+ end
35
+ end
36
+
37
+ def validate(lcov_report_path)
38
+ return :no_changes if file_paths.empty?
39
+ return :stale_coverage if last_modified > File.mtime(lcov_report_path)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pronto'
4
+ require 'undercover/options'
5
+ require 'undercover'
6
+ require 'pronto/patch_changeset'
7
+
8
+ module Pronto
9
+ # Runner class for undercover
10
+ class Undercover < Runner
11
+ DEFAULT_LEVEL = :warning
12
+
13
+ def initialize(patches, _commit = nil)
14
+ super
15
+ @patch_changeset = Pronto::PatchChangeset.new(patches)
16
+ end
17
+
18
+ # @return Array[Pronto::Message]
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))
25
+ rescue Errno::ENOENT => e
26
+ warn("Could not open file! #{e}")
27
+ []
28
+ end
29
+
30
+ private
31
+
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)
44
+ end
45
+ # rubocop:enable Metrics/AbcSize
46
+
47
+ def untested_lines_for(warning)
48
+ warning.coverage.map do |ln, _cov|
49
+ ln if warning.uncovered?(ln)
50
+ end.compact
51
+ end
52
+
53
+ def undercover_options
54
+ config = Pronto::ConfigFile.new.to_h
55
+ opts = []
56
+ opts << "-l#{config['lcov']}" if config['lcov']
57
+ opts << "-r#{config['ruby-syntax']}" if config['ruby-syntax']
58
+ opts << "-p#{config['path']}" if config['path']
59
+ ::Undercover::Options.new.parse(opts)
60
+ end
61
+ end
62
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pronto
4
+ module UndercoverVersion
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'pronto-undercover'
9
+ spec.version = Pronto::UndercoverVersion::VERSION
10
+ spec.authors = ['Jan Grodowski']
11
+ spec.email = ['jgrodowski@gmail.com']
12
+
13
+ spec.summary = 'Pronto runner for Undercover - actionable code coverage'
14
+ spec.homepage = 'https://github.com/grodowski/pronto-undercover'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(/^(test|spec|features)\//)
19
+ end
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'pronto', '~> 0.9.0'
23
+ spec.add_dependency 'undercover', '~> 0.2.0'
24
+ spec.add_development_dependency 'pry'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'simplecov'
29
+ spec.add_development_dependency 'simplecov-html'
30
+ spec.add_development_dependency 'simplecov-lcov'
31
+ spec.add_development_dependency 'timecop'
32
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-undercover
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Grodowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: undercover
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov-html
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov-lcov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: timecop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email:
155
+ - jgrodowski@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".rubocop.yml"
163
+ - ".travis.yml"
164
+ - Gemfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - lib/pronto/patch_changeset.rb
169
+ - lib/pronto/undercover.rb
170
+ - lib/version.rb
171
+ - pronto-undercover.gemspec
172
+ homepage: https://github.com/grodowski/pronto-undercover
173
+ licenses:
174
+ - MIT
175
+ metadata: {}
176
+ post_install_message:
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubyforge_project:
192
+ rubygems_version: 2.7.6
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: Pronto runner for Undercover - actionable code coverage
196
+ test_files: []