Skip to content

Commit

Permalink
use strrep
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Dec 6, 2023
1 parent 953c922 commit 74d7f64
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions R/vector_logic_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,16 @@ vector_logic_linter <- function() {
]
"

scalar_map <- c(AND = "&&", OR = "||")

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())
bad_expr <- xml_find_all(xml, xpath)

op <- xml_name(bad_expr)
op <- xml_text(bad_expr)
xml_nodes_to_lints(
bad_expr,
source_expression = source_expression,
lint_message = sprintf("Use `%s` in conditional expressions.", scalar_map[op]),
lint_message = sprintf("Use `%s` in conditional expressions.", strrep(op, 2L)),
type = "warning"
)
})
Expand Down

0 comments on commit 74d7f64

Please sign in to comment.