Skip to contents

Replaces the argument of every return(expr) with a fixed value (default "NULL"). Tests that only check that a function returns something without asserting the value will not kill these mutants.

Usage

replace_return_value(replacement = "NULL")

Arguments

replacement

Raw R source text to substitute as the return value. Defaults to "NULL". Examples: "NA" inserts the missing value NA; '"NULL"' (inner quotes) inserts the string "NULL"; '"NA"' inserts the string "NA" rather than the missing value.

Value

A Mutator object.

Details

Only explicit return() calls are targeted. Implicit returns (the last expression of a function body) are not affected.

Examples

replace_return_value()
#> Mutator: return(<value>) → return(NULL)
#> Query: (call function: (return) arguments: (arguments (argument value: (_) @value)))
replace_return_value("NA")
#> Mutator: return(<value>) → return(NA)
#> Query: (call function: (return) arguments: (arguments (argument value: (_) @value)))