make_linter_from_xpath: Create a linter from an XPath

View source: R/make_linter_from_xpath.R

make_linter_from_xpathR Documentation

Create a linter from an XPath

Description

Create a linter from an XPath

Usage

make_linter_from_xpath(
  xpath,
  lint_message,
  type = c("warning", "style", "error"),
  level = c("expression", "file")
)

make_linter_from_function_xpath(
  function_names,
  xpath,
  lint_message,
  type = c("warning", "style", "error"),
  level = c("expression", "file")
)

Arguments

xpath

Character string, an XPath identifying R code to lint. For make_linter_from_function_xpath(), the XPath is relative to the SYMBOL_FUNCTION_CALL nodes of the selected functions. See xmlparsedata::xml_parse_data() and get_source_expressions().

lint_message

The message to be included as the message to the Lint object. If lint_message is a character vector the same length as xml, the i-th lint will be given the i-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())

jimhester/lintr documentation built on April 24, 2024, 8:21 a.m.