Skip to content

Commit 4f84461

Browse files
committed
Test simplecov v1.0.0.rc3
1 parent 7fc9ca6 commit 4f84461

10 files changed

Lines changed: 17 additions & 44 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $ mdformat . --number
5353

5454
### Test Coverage - Line and Branch
5555

56-
We are using [Simplecov](https://github.com/colszowka/simplecov) to track test coverage.
56+
We are using [Simplecov](https://github.com/simplecov-ruby/simplecov) to track test coverage.
5757

5858
It is included and reported when you run `bundle exec rake` or `bundle exec rspec`.
5959

@@ -65,20 +65,19 @@ E.g. on macOS:
6565
$ open coverage/index.html
6666
```
6767

68-
If you have unreachable lines, you can add `# :nocov` around those lines. The code itself or a comment should explain why the line is unreachable.
68+
If you have unreachable lines, you can add `# simplecov:disable`/`# simplecov:enable` around those lines. The code itself or a comment should explain why the line is unreachable.
6969

7070
Example:
7171

7272
```ruby
73-
# :nocov:
73+
# simplecov:disable
7474
raise ArgumentError("Unsupported style :#{style}")
75-
# :nocov:
75+
# simplecov:enable
7676
```
7777

7878
This can happen for a few reasons, including:
7979

80-
1. When you handle config with a case statement and there is no else block.
81-
2. When matching with a node pattern even when you handle all cases: all other node types will be excluded before reaching your handler, because the node pattern will not match them.
80+
- When matching with a node pattern even when you handle all cases: all other node types will be excluded before reaching your handler, because the node pattern will not match them.
8281

8382
You will need full line and branch coverage to merge. This helps detect edge cases and prevent errors.
8483

.simplecov

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# frozen_string_literal: true
22

3-
SimpleCov.start do
4-
enable_coverage :branch
5-
minimum_coverage line: 100, branch: 100
6-
add_filter '/spec/'
7-
add_filter '/vendor/bundle/'
8-
end
3+
SimpleCov.enable_coverage :branch
4+
SimpleCov.minimum_coverage line: 100, branch: 100
5+
SimpleCov.ignore_branches :implicit_else
6+
SimpleCov.skip '/spec/'
7+
SimpleCov.skip '/vendor/bundle/'

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gem 'rake'
1111
gem 'rspec', '~> 3.11'
1212
gem 'rubocop-performance', '~> 1.24'
1313
gem 'rubocop-rake', '~> 0.7'
14-
gem 'simplecov', '>= 0.19'
14+
gem 'simplecov', '1.0.0.rc3' if RUBY_VERSION >= '3.1'
1515
gem 'yard'
1616

1717
# FIXME: Remove when the next prism version is released.

lib/rubocop/cop/rspec/be_nil.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ def on_send(node)
4848
check_be_style(node)
4949
when :be_nil
5050
check_be_nil_style(node)
51-
else
52-
# :nocov:
53-
:noop
54-
# :nocov:
5551
end
5652
end
5753

lib/rubocop/cop/rspec/implicit_subject.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ def autocorrect(corrector, node)
107107
corrector.replace(node.location.selector, 'expect(subject).to')
108108
when :should_not
109109
corrector.replace(node.location.selector, 'expect(subject).not_to')
110-
else
111-
# :nocov:
112-
:noop
113-
# :nocov:
114110
end
115111
end
116112

@@ -133,10 +129,6 @@ def invalid?(node)
133129
implicit_subject_in_non_its_and_non_single_line?(node)
134130
when :single_statement_only
135131
implicit_subject_in_non_its_and_non_single_statement?(node)
136-
else
137-
# :nocov:
138-
:noop
139-
# :nocov:
140132
end
141133
end
142134

lib/rubocop/cop/rspec/message_spies.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ def error_message(receiver)
8080
MSG_RECEIVE
8181
when :have_received
8282
format(MSG_HAVE_RECEIVED, source: receiver.source)
83-
else
84-
# :nocov:
85-
:noop
86-
# :nocov:
8783
end
8884
end
8985
end

lib/rubocop/cop/rspec/predicate_matcher.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ def true?(to_symbol, matcher)
116116
true
117117
when :be_falsey, :be_falsy, :a_falsey_value, :a_falsy_value
118118
false
119-
else
120-
# :nocov:
121-
:noop
122-
# :nocov:
123119
end
124120
to_symbol == :to ? result : !result
125121
end
@@ -333,10 +329,6 @@ def on_send(node)
333329
check_inflected(node)
334330
when :explicit
335331
check_explicit(node)
336-
else
337-
# :nocov:
338-
:noop
339-
# :nocov:
340332
end
341333
end
342334

lib/rubocop/cop/rspec/spec_file_path_format.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ def inflector
106106
ActiveSupportInflector
107107
when 'default'
108108
DefaultInflector
109-
else
110-
# :nocov:
111-
:noop
112-
# :nocov:
113109
end
114110
end
115111

lib/rubocop/rspec/plugin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module RuboCop
66
module RSpec
77
# A plugin that integrates RuboCop RSpec with RuboCop's plugin system.
88
class Plugin < LintRoller::Plugin
9-
# :nocov:
9+
# simplecov:disable
1010
def about
1111
LintRoller::About.new(
1212
name: 'rubocop-rspec',
@@ -15,7 +15,7 @@ def about
1515
description: 'Code style checking for RSpec files.'
1616
)
1717
end
18-
# :nocov:
18+
# simplecov:enable
1919

2020
def supported?(context)
2121
context.engine == :rubocop

spec/spec_helper.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
require 'rubocop'
44
require 'rubocop/rspec/support'
55

6-
require 'simplecov' unless ENV['NO_COVERAGE']
6+
unless ENV['NO_COVERAGE'] || RUBY_VERSION < '3.1'
7+
require 'simplecov'
8+
SimpleCov.start
9+
end
710

811
module SpecHelper
912
ROOT = Pathname.new(__dir__).parent.freeze

0 commit comments

Comments
 (0)