Skip to contents

The inverse of negate_condition(). Strips the leading ! from any already-negated condition, so if (!done) becomes if (done) and while (!ready) becomes while (ready).

Usage

remove_condition_negation(statements = c("if", "while"))

Arguments

statements

Character vector of statement types to target. Must be a subset of c("if", "while"). Defaults to both.

Value

A Mutator object.

Details

Unlike remove_negation(), this mutator is scoped exclusively to conditions, leaving negations in other positions (assignments, return values, etc.) untouched.

Examples

remove_condition_negation()
#> Mutator: !<condition> → <condition>
#> Query: [(if_statement condition: (_) @cond) (while_statement condition: (_) @cond)]
remove_condition_negation(statements = "while")
#> Mutator: !<condition> → <condition>
#> Query: (while_statement condition: (_) @cond)