Create a linter from an XPath
Arguments
- xpath
Character string, an XPath identifying R code to lint. For
make_linter_from_function_xpath()
, the XPath is relative to theSYMBOL_FUNCTION_CALL
nodes of the selected functions. Seexmlparsedata::xml_parse_data()
andget_source_expressions()
.- lint_message
The message to be included as the
message
to theLint
object. Iflint_message
is a character vector the same length asxml
, thei
-th lint will be given thei
-th message.- type
type of lint.
- level
Which level of expression is being tested?
"expression"
means an individual expression, while"file"
means all expressions in the current file are available.- function_names
Character vector, names of functions whose calls to examine..
Examples
number_linter <- make_linter_from_xpath("//NUM_CONST", "This is a number.")
lint(text = "1 + 2", linters = number_linter())
#> <text>:1:1: warning: [number_linter] This is a number.
#> 1 + 2
#> ^
#> <text>:1:5: warning: [number_linter] This is a number.
#> 1 + 2
#> ^