Skip to content

Commit 83081e9

Browse files
committed
Remove nested ifelse()
1 parent 8be9818 commit 83081e9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

R/sprintf_linter.R

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,13 @@ sprintf_linter <- function() {
102102
sprintf_calls,
103103
"SYMBOL_SUB[text() = 'fmt']/following-sibling::expr[1]/STR_CONST"
104104
)
105-
fmt_by_pos <- get_r_string(
106-
sprintf_calls,
107-
"OP-LEFT-PAREN/following-sibling::expr[1]/STR_CONST"
108-
)
109-
fmt_by_pos_piped <- get_r_string(
110-
sprintf_calls,
111-
"preceding-sibling::*[2]/STR_CONST"
105+
fmt_by_pos <- ifelse(
106+
in_pipeline,
107+
get_r_string(sprintf_calls, "preceding-sibling::*[2]/STR_CONST"),
108+
get_r_string(sprintf_calls, "OP-LEFT-PAREN/following-sibling::expr[1]/STR_CONST")
112109
)
113110

114-
fmt <- ifelse(!is.na(fmt_by_name), fmt_by_name, ifelse(in_pipeline, fmt_by_pos_piped, fmt_by_pos))
111+
fmt <- ifelse(!is.na(fmt_by_name), fmt_by_name, fmt_by_pos)
115112
constant_fmt <- !is.na(fmt) & !grepl("%[^%]", fmt)
116113

117114
constant_fmt_lint <- xml_nodes_to_lints(

0 commit comments

Comments
 (0)