extract all if-else statements from a function

I'd like to convert initial if else statements in a function to a list of expressions so that I can more efficiently ensure compatibility between real and expected input data. Is there a way to extract any set of if statements of the form

if (some expression){
some code }

into a list of expressions?

This is what I've tried

stringr::str_extract_all(rlang::expr_text(rlang::expr_text), "if.*\\{")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.