module SimpleCov::StaticCoverageExtractor::ConditionFolding
def static_condition?(node)
versions, so matching it would trade a rare, version-specific gain
folds, and `||` / `&&` constant-propagation diverges across Ruby
forms (`!true`, `true || x`) are deliberately not folded: `!` never
`if 1`), so see through a single parenthesized expression. Compound
Parentheses are transparent to the fold (`if (1)` folds like
def static_condition?(node) node = unwrap_parentheses(node) STATIC_CONDITION_TYPES.any? { |type| node.is_a?(type) } end
def unwrap_parentheses(node)
def unwrap_parentheses(node) # @type var current: untyped current = node while current.is_a?(::Prism::ParenthesesNode) body = current.body break unless body.is_a?(::Prism::StatementsNode) && body.body.size == 1 current = body.body.first end current end