undercover 0.1.2 → 0.1.3

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
- SHA1:
3
- metadata.gz: 4912afdc776b0f9799d09f6fa347a3991683b3bd
4
- data.tar.gz: 9cb73276512755b47bcb49cf6e39264643f0dd2b
2
+ SHA256:
3
+ metadata.gz: f5a66a64143952a6005a4198ca9887868fb4d945fb2f8eae7285b015fecccd37
4
+ data.tar.gz: 7dfb19c17f81762209c03a763a9fc2e49f007693195a367698bdc96afce77b4f
5
5
  SHA512:
6
- metadata.gz: f32ef0b88a932b5c15930440a2e7f9ad474facfc9ba9ddbac1b4188244695ab60682d45f373348fd4ed8f4b2dfc91e51ee5823f4a69d3bfecf2c8ce44041cfb6
7
- data.tar.gz: 25ccb7bdf904cb8205434025f73ce4b3b69ccaeead0eaa5ea6013edfdf0e61c4f7bcd95ad83aea293b5d0523cffa5adacc19e0165c2e3dfddd4c5382823ee8d4
6
+ metadata.gz: 81f95df75a46c1a5b1814d8ab6438793dc37ac4168af4336938e0cfd3239aa4891659fcc66d2c3331480263fb69e486ac895c371c9347cc53dd77a741f9613ae
7
+ data.tar.gz: d1edd837513823ffc935eb1aaebe01fb3a4b6c1a3d085a00ca328bfe6678a3eaf80e539151236974cbe42f91092558aad89e18d6a1db9b615eef42e7f32902b5
@@ -0,0 +1,7 @@
1
+ {
2
+ "RUBY": {
3
+ "ABC": [15, 20, 25, 30],
4
+ "CYCLO": [15, 20, 25, 30],
5
+ "LOC": [8, 10, 12, 20]
6
+ }
7
+ }
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ Gemfile.lock
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /_yardoc/
@@ -8,7 +8,7 @@ Style/RegexpLiteral:
8
8
  Style/Documentation:
9
9
  Enabled: false
10
10
 
11
- Style/SpaceInsideHashLiteralBraces:
11
+ Layout/SpaceInsideHashLiteralBraces:
12
12
  Enabled: true
13
13
  EnforcedStyle: no_space
14
14
 
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  **RuboCop for code coverage**
4
4
 
5
- Meaningful warnings for methods and classes which lack testing, using data from coverage reports, git metadata and a parsed structure of your Ruby codebase. `undercover` automates the coverage feedback loop and makes sure no code review passes without tests.
5
+ **Inspects files in a git diff and warns on methods, classes and blocks which need test coverage.** Use it locally or as part of an automated build to shorten your code coverage feedback loop!
6
+
7
+ Technically, `undercover` combines data from git, coverage reports and code structure graphs.
6
8
 
7
9
  A sample output of `undercover` ran before a commit may look like this:
8
10
 
@@ -36,8 +38,6 @@ Or install it yourself as:
36
38
 
37
39
  ## Setting up required LCOV reporting
38
40
 
39
- Undercover depends on a git diff, code structure generated by [`imagen`](https://github.com/grodowski/imagen_rb) and a coverage report in LCOV format.
40
-
41
41
  To make your specs compatible with `undercover` by providing an LCOV report, please add `simplecov` and `simplecov-lcov` to your test setup. Example for rspec:
42
42
 
43
43
  ```ruby
@@ -96,7 +96,7 @@ The defaults assume that the program is run from the top level of the project di
96
96
 
97
97
  ## Development
98
98
 
99
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
99
+ After checking out the repo, run `bundle` to install dependencies. Then, run `rake` to run the tests and RuboCop. You can also run `pry -r 'undercover'` for an interactive prompt that will allow you to experiment.
100
100
 
101
101
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
102
102
 
@@ -11,5 +11,5 @@ time = Benchmark.realtime do
11
11
  result = Undercover::CLI.run(ARGV)
12
12
  end
13
13
 
14
- puts "Undercover finished in #{time}ms"
14
+ puts "Undercover finished in #{time.round(4)}s"
15
15
  exit result
@@ -21,19 +21,25 @@ module Undercover
21
21
 
22
22
  attr_reader :changeset,
23
23
  :lcov,
24
- :results
24
+ :results,
25
+ :code_dir
25
26
 
26
- # TODO: pass merge base as cli argument
27
- # add dependecy on "options" for all opts (dirs, git_dir, etc)
28
- def initialize(lcov_report_path, code_dir, git_dir: '.git', compare: nil)
29
- @lcov = LcovParser.parse(File.open(lcov_report_path))
30
- @changeset = Changeset.new(File.join(code_dir, git_dir), compare).update
27
+ # Initializes a new Undercover::Report
28
+ #
29
+ # @param options [Undercover::Options]
30
+ def initialize(opts)
31
+ @lcov = LcovParser.parse(File.open(opts.lcov))
32
+ @code_dir = opts.path
33
+ git_dir = File.join(opts.path, opts.git_dir)
34
+ @changeset = Changeset.new(git_dir, opts.compare).update
31
35
  @results = Hash.new { |hsh, key| hsh[key] = [] }
32
36
  end
33
37
 
34
38
  def build
35
39
  each_result_arg do |filename, coverage, imagen_node|
36
- results[filename] << Result.new(imagen_node, coverage, filename)
40
+ results[filename.gsub(/^\.\//, '')] << Result.new(
41
+ imagen_node, coverage, filename
42
+ )
37
43
  end
38
44
  self
39
45
  end
@@ -69,17 +75,16 @@ module Undercover
69
75
 
70
76
  private
71
77
 
72
- # TODO: some of this could be moved to the imagen gem
73
78
  # TODO: should that start from changeset.file_paths?
74
79
  # this way we could report things that weren't even loaded in any spec,
75
80
  # so is this still good idea? (Rakefile, .gemspec etc)
76
81
  def each_result_arg
77
82
  match_all = ->(_) { true }
78
83
  lcov.source_files.each do |filename, coverage|
79
- ast = Imagen::Node::Root.new
80
- Imagen::Visitor.traverse(Parser::CurrentRuby.parse_file(filename), ast)
81
- ast.children[0].find_all(match_all).each do |node|
82
- yield(filename, coverage, node)
84
+ path = File.join(code_dir, filename)
85
+ root_ast = Imagen::Node::Root.new.build_from_file(path)
86
+ root_ast.children[0].find_all(match_all).each do |node|
87
+ yield(path, coverage, node)
83
88
  end
84
89
  end
85
90
  end
@@ -16,16 +16,9 @@ module Undercover
16
16
 
17
17
  WARNINGS_TO_EXITCODE = {stale_coverage: 1, no_changes: 0}.freeze
18
18
 
19
- # TODO: add executable in ./bin later
20
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
21
19
  def self.run(args)
22
20
  opts = Undercover::Options.new.parse(args)
23
- report = Undercover::Report.new(
24
- opts.lcov,
25
- opts.path,
26
- git_dir: opts.git_dir,
27
- compare: opts.compare
28
- ).build
21
+ report = Undercover::Report.new(opts).build
29
22
 
30
23
  error = report.validate(opts.lcov)
31
24
  if error
@@ -37,6 +30,5 @@ module Undercover
37
30
  puts Undercover::Formatter.new(warnings)
38
31
  warnings.any? ? 1 : 0
39
32
  end
40
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
41
33
  end
42
34
  end
@@ -25,7 +25,6 @@ module Undercover
25
25
  @run_mode = RUN_MODE_DIFF_STRICT
26
26
  @enabled_formatters = [OUTPUT_STDOUT]
27
27
  # set defaults
28
- self.lcov = guess_lcov_path
29
28
  self.path = '.'
30
29
  self.git_dir = '.git'
31
30
  end
@@ -54,6 +53,7 @@ module Undercover
54
53
  # --exit-status (do not print report, just exit)
55
54
  # --ruby-version (string, like '2.4.4', how to support in parser?)
56
55
  end.parse(args)
56
+ guess_lcov_path unless lcov
57
57
  self
58
58
  end
59
59
  # rubocop:enable Metrics/MethodLength
@@ -87,8 +87,8 @@ module Undercover
87
87
  end
88
88
 
89
89
  def guess_lcov_path
90
- pwd = Pathname.pwd
91
- File.join(pwd, 'coverage', 'lcov', "#{pwd.split.last}.lcov")
90
+ cwd = Pathname.new(File.expand_path(path))
91
+ self.lcov = File.join(cwd, 'coverage', 'lcov', "#{cwd.split.last}.lcov")
92
92
  end
93
93
  end
94
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Undercover
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_dependency 'imagen', '~> 0.1.1'
25
+ spec.add_dependency 'imagen', '~> 0.1.2'
26
26
  spec.add_dependency 'rainbow', '~> 3.0.0'
27
27
  spec.add_dependency 'rugged', '~> 0.27.0'
28
28
 
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.1.2
4
+ version: 0.1.3
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-05-18 00:00:00.000000000 Z
11
+ date: 2018-05-20 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.1
19
+ version: 0.1.2
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.1
26
+ version: 0.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rainbow
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -172,12 +172,12 @@ executables:
172
172
  extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
+ - ".codebeatsettings"
175
176
  - ".gitignore"
176
177
  - ".rspec"
177
178
  - ".rubocop.yml"
178
179
  - ".travis.yml"
179
180
  - Gemfile
180
- - Gemfile.lock
181
181
  - LICENSE.txt
182
182
  - README.md
183
183
  - Rakefile
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  requirements: []
215
215
  rubyforge_project:
216
- rubygems_version: 2.6.14.1
216
+ rubygems_version: 2.7.6
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Actionable code coverage - detects untested code blocks in recent changes
@@ -1,76 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- undercover (0.1.2)
5
- imagen (~> 0.1.1)
6
- rainbow (~> 3.0.0)
7
- rugged (~> 0.27.0)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- ast (2.4.0)
13
- coderay (1.1.2)
14
- diff-lcs (1.3)
15
- docile (1.3.0)
16
- imagen (0.1.1)
17
- parser
18
- json (2.1.0)
19
- method_source (0.9.0)
20
- parallel (1.12.1)
21
- parser (2.5.1.0)
22
- ast (~> 2.4.0)
23
- powerpack (0.1.1)
24
- pry (0.11.3)
25
- coderay (~> 1.1.0)
26
- method_source (~> 0.9.0)
27
- rainbow (3.0.0)
28
- rake (10.5.0)
29
- rspec (3.7.0)
30
- rspec-core (~> 3.7.0)
31
- rspec-expectations (~> 3.7.0)
32
- rspec-mocks (~> 3.7.0)
33
- rspec-core (3.7.1)
34
- rspec-support (~> 3.7.0)
35
- rspec-expectations (3.7.0)
36
- diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.7.0)
38
- rspec-mocks (3.7.0)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.7.0)
41
- rspec-support (3.7.1)
42
- rubocop (0.55.0)
43
- parallel (~> 1.10)
44
- parser (>= 2.5)
45
- powerpack (~> 0.1)
46
- rainbow (>= 2.2.2, < 4.0)
47
- ruby-progressbar (~> 1.7)
48
- unicode-display_width (~> 1.0, >= 1.0.1)
49
- ruby-progressbar (1.9.0)
50
- rugged (0.27.0)
51
- simplecov (0.16.1)
52
- docile (~> 1.1)
53
- json (>= 1.8, < 3)
54
- simplecov-html (~> 0.10.0)
55
- simplecov-html (0.10.2)
56
- simplecov-lcov (0.7.0)
57
- timecop (0.9.1)
58
- unicode-display_width (1.3.2)
59
-
60
- PLATFORMS
61
- ruby
62
- x86_64-darwin-17
63
-
64
- DEPENDENCIES
65
- bundler (~> 1.16)
66
- pry
67
- rake (~> 10.0)
68
- rspec (~> 3.0)
69
- rubocop (~> 0.55.0)
70
- simplecov
71
- simplecov-lcov
72
- timecop
73
- undercover!
74
-
75
- BUNDLED WITH
76
- 1.16.2