Class: RuboCop::Cop::Minitest::SkipWithoutReason

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/minitest/skip_without_reason.rb

Overview

Checks for skipped tests missing the skipping reason.

Examples:

# bad
skip
skip('')

# bad
if condition?
  skip
else
  skip
end

# good
skip("Reason why the test was skipped")

# good
skip if condition?

Constant Summary collapse

MSG =
'Add a reason explaining why the test is skipped.'
RESTRICT_ON_SEND =
%i[skip].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/rubocop/cop/minitest/skip_without_reason.rb', line 31

def on_send(node)
  return if node.receiver || !blank_argument?(node)

  conditional_node = conditional_parent(node)
  return if conditional_node && !only_skip_branches?(conditional_node)

  return if node.parent&.resbody_type?

  add_offense(node)
end