Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell SimpleCov to ignore unreachable code #2034

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SimpleCov.start do
enable_coverage :branch
minimum_coverage line: 100, branch: 98.44
minimum_coverage line: 100, branch: 100
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corsonknowles Yay ✨

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩👏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ :shipit: 🥇

add_filter '/spec/'
add_filter '/vendor/bundle/'
end
4 changes: 4 additions & 0 deletions lib/rubocop/cop/rspec/be_nil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def on_send(node)
check_be_style(node)
when :be_nil
check_be_nil_style(node)
else
# :nocov:
:noop
# :nocov:
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/example_wording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def text(node)
node.node_parts.map { |child_node| text(child_node) }.join
when :str
node.value
when :begin
else
node.source
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/excessive_docstring_spacing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def text(node)
node.node_parts.map { |child_node| text(child_node) }.join
when :str, :sym
node.value
when :begin
else
node.source
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/rubocop/cop/rspec/implicit_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def on_send(node)

private

# rubocop:disable Metrics/MethodLength
def autocorrect(corrector, node)
case node.method_name
when :expect
Expand All @@ -107,8 +108,13 @@ def autocorrect(corrector, node)
corrector.replace(node.location.selector, 'expect(subject).to')
when :should_not
corrector.replace(node.location.selector, 'expect(subject).not_to')
else
# :nocov:
:noop
# :nocov:
end
end
# rubocop:enable Metrics/MethodLength

def message(_node)
case style
Expand All @@ -119,6 +125,7 @@ def message(_node)
end
end

# rubocop:disable Metrics/MethodLength
def invalid?(node)
case style
when :require_implicit
Expand All @@ -129,8 +136,13 @@ def invalid?(node)
implicit_subject_in_non_its_and_non_single_line?(node)
when :single_statement_only
implicit_subject_in_non_its_and_non_single_statement?(node)
else
# :nocov:
:noop
# :nocov:
end
end
# rubocop:enable Metrics/MethodLength

def implicit_subject_in_non_its?(node)
implicit_subject?(node) && !its?(node)
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/rspec/message_spies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def error_message(receiver)
MSG_RECEIVE
when :have_received
format(MSG_HAVE_RECEIVED, source: receiver.source)
else
# :nocov:
:noop
# :nocov:
end
end
end
Expand Down
12 changes: 11 additions & 1 deletion lib/rubocop/cop/rspec/predicate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def rewrite_matcher(corrector, predicate, matcher)
)
end

# rubocop:disable Metrics/MethodLength
def true?(to_symbol, matcher)
result = case matcher.method_name
when :be, :eq, :eql, :equal
Expand All @@ -118,9 +119,14 @@ def true?(to_symbol, matcher)
true
when :be_falsey, :be_falsy, :a_falsey_value, :a_falsy_value
false
else
# :nocov:
:noop
# :nocov:
end
to_symbol == :to ? result : !result
end
# rubocop:enable Metrics/MethodLength
end

# A helper for `explicit` style
Expand Down Expand Up @@ -266,7 +272,7 @@ def replacement_matcher(node)
'be(false)'
when [false, true]
'be_truthy'
when [false, false]
else
'be_falsey'
end
end
Expand Down Expand Up @@ -335,6 +341,10 @@ def on_send(node)
check_inflected(node)
when :explicit
check_explicit(node)
else
# :nocov:
:noop
# :nocov:
end
end

Expand Down