simplecov-review 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: b1d9deaba10268b776c6498b55c64035273b4eef4f15321dc8e8d035f80408c2
4
+ data.tar.gz: c5da36f9691120017450ac9ccb6d6d80fd1f347f40c567f043124bfef50a8888
5
+ SHA512:
6
+ metadata.gz: d717454cfb87c084a8e93c63899059b77181d1d3679eff6236e70aae645503716721d7b8cf61dc70074a056772f16c08b1b81d7aa1fb849e304ae50600f403e3
7
+ data.tar.gz: 29977bbafbf8b17916f63f0c8247af6da82b1c016c6f0309532e4c24e1057d363625e91bc1eca9ca517428af828d8d6297120df9e4e2eca4f34a8dc78e18cfdc
@@ -0,0 +1,22 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [2.5, 2.6, 2.7, 3.0]
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler-cache: true
19
+ - name: Run RSpec
20
+ run: bundle exec rspec
21
+ - name: Run Rubocop
22
+ run: bundle exec rubocop
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.5
6
+ NewCops: enable
7
+
8
+ Naming/FileName:
9
+ Exclude:
10
+ - "lib/simplecov-review.rb"
11
+ - "spec/simplecov-review_spec.rb"
12
+
13
+ RSpec/NamedSubject:
14
+ Enabled: false
15
+
16
+ RSpec/FilePath:
17
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-10-19
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in simplecov-review.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 1.7'
11
+ gem 'rubocop-rspec', '~> 2.5'
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simplecov-review (0.1.0)
5
+ simplecov (~> 0.21.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.4.4)
12
+ docile (1.3.5)
13
+ parallel (1.21.0)
14
+ parser (3.0.2.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.0.0)
17
+ rake (13.0.6)
18
+ regexp_parser (2.1.1)
19
+ rexml (3.2.5)
20
+ rspec (3.10.0)
21
+ rspec-core (~> 3.10.0)
22
+ rspec-expectations (~> 3.10.0)
23
+ rspec-mocks (~> 3.10.0)
24
+ rspec-core (3.10.1)
25
+ rspec-support (~> 3.10.0)
26
+ rspec-expectations (3.10.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-mocks (3.10.2)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.10.0)
32
+ rspec-support (3.10.2)
33
+ rubocop (1.22.1)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.0.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml
39
+ rubocop-ast (>= 1.12.0, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 1.4.0, < 3.0)
42
+ rubocop-ast (1.12.0)
43
+ parser (>= 3.0.1.1)
44
+ rubocop-rspec (2.5.0)
45
+ rubocop (~> 1.19)
46
+ ruby-progressbar (1.11.0)
47
+ simplecov (0.21.2)
48
+ docile (~> 1.1)
49
+ simplecov-html (~> 0.11)
50
+ simplecov_json_formatter (~> 0.1)
51
+ simplecov-html (0.12.3)
52
+ simplecov_json_formatter (0.1.2)
53
+ unicode-display_width (2.1.0)
54
+
55
+ PLATFORMS
56
+ x86_64-darwin-18
57
+ x86_64-linux
58
+
59
+ DEPENDENCIES
60
+ rake (~> 13.0)
61
+ rspec (~> 3.0)
62
+ rubocop (~> 1.7)
63
+ rubocop-rspec (~> 2.5)
64
+ simplecov-review!
65
+
66
+ BUNDLED WITH
67
+ 2.2.17
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Karol Bąk
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,70 @@
1
+ # simplecov-review
2
+
3
+ SimpleCov formatter to generate missing lines errors for reporting tools
4
+ like [reviewdog](https://github.com/reviewdog/reviewdog). It creates `coverage/review.txt` file containing uncovered
5
+ lines in a format that can be easily used with reviewdog.
6
+
7
+ Example:
8
+
9
+ ```
10
+ app/controllers/admin/companies_controller.rb:16:1: Missing coverage for line 16
11
+ app/controllers/admin/company_owners_controller.rb:17:1: Missing coverage for line 17
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ group :test do
20
+ gem 'simplecov-review', require: false
21
+ end
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle install
27
+
28
+ ## Usage
29
+
30
+ Require the library in your `spec_helper.rb` and set it as your SimpleCov formatter:
31
+
32
+ ```ruby
33
+ require 'simplecov'
34
+ require 'simplecov-review'
35
+
36
+ SimpleCov.start do
37
+ formatter SimpleCov::Formatter::ReviewFormatter
38
+ end
39
+ ```
40
+
41
+ ### Reviewdog integration
42
+
43
+ Since in your workflow rspec will be executed before reviewdog, make sure to disable minimum coverage check in
44
+ SimpleCov since it will stop the process in case the coverage is below threshold or configure you CI to execute it anyway (on GitHub Actions use `if: always()`).
45
+
46
+ To report uncovered lines with reviewdog, add following lines to `.reviewdog.yml`:
47
+
48
+ ```yaml
49
+ runner:
50
+ # other checks
51
+ coverage:
52
+ cmd: cat coverage/review.txt
53
+ level: warning
54
+ errorformat:
55
+ - "%f:%l:%c: %m"
56
+ ```
57
+
58
+ Result:
59
+
60
+ ![reviewdog result](https://kukicola.io/assets/img/review/missing-coverage.png)
61
+
62
+ If you require 100% line coverage in your project change `level` value to `error`.
63
+
64
+ ## Roadmap
65
+
66
+ * add branch coverage support
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kukicola/simplecov-review.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ module Formatter
5
+ class ReviewFormatter
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'simplecov-review/version'
4
+
5
+ module SimpleCov
6
+ module Formatter
7
+ FILENAME = 'review.txt'
8
+ #
9
+ # Simple formatter to report missing coverage for reporting tools
10
+ #
11
+ class ReviewFormatter
12
+ def format(result)
13
+ File.open(export_path, 'w') do |output_file|
14
+ result.files.each do |file|
15
+ find_missing_groups(file).each do |lines|
16
+ output_file << error_for(file, lines)
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def error_for(file, lines)
25
+ filename = file.filename.gsub("#{SimpleCov.root}/", '')
26
+ message = if lines.length > 1
27
+ "Missing coverage for lines #{lines.first}-#{lines.last}"
28
+ else
29
+ "Missing coverage for line #{lines.first}"
30
+ end
31
+ "#{filename}:#{lines.first}:1: #{message}\n"
32
+ end
33
+
34
+ def find_missing_groups(file)
35
+ lines_missing = file.lines.each_index.select { |index| file.lines[index].coverage&.zero? }.map { |l| l + 1 }
36
+ lines_missing.slice_when { |prev, curr| curr != prev.next }.to_a
37
+ end
38
+
39
+ def export_path
40
+ File.join(SimpleCov.coverage_path, FILENAME)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/simplecov-review/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'simplecov-review'
7
+ spec.version = SimpleCov::Formatter::ReviewFormatter::VERSION
8
+ spec.authors = ['Karol Bąk']
9
+ spec.email = ['kukicola@gmail.com']
10
+
11
+ spec.summary = 'SimpleCov formatter to generate missing lines errors for reporting tools like reviewdog'
12
+ spec.homepage = 'https://github.com/kukicola/simplecov-review'
13
+ spec.required_ruby_version = '>= 2.5.0'
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = spec.homepage
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'simplecov', '~> 0.21.2'
26
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-review
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Karol Bąk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: simplecov
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.21.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.21.2
27
+ description:
28
+ email:
29
+ - kukicola@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/main.yml"
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CHANGELOG.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - lib/simplecov-review.rb
45
+ - lib/simplecov-review/version.rb
46
+ - simplecov-review.gemspec
47
+ homepage: https://github.com/kukicola/simplecov-review
48
+ licenses: []
49
+ metadata:
50
+ homepage_uri: https://github.com/kukicola/simplecov-review
51
+ source_code_uri: https://github.com/kukicola/simplecov-review
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.5.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.0.6
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: SimpleCov formatter to generate missing lines errors for reporting tools
71
+ like reviewdog
72
+ test_files: []