R/aaa.R

Defines functions box_package_base_path box_module_base_path

Documented in box_module_base_path box_package_base_path

#' Find `box::use` calls for local modules
#'
#' @details
#' Base XPath to find `box::use` declarations that match the following pattern:
#' \code{
#' box::use(
#'   path/to/module,
#' )
#' }
#'
#' @seealso [box_separate_calls_linter()]
#'
#' @return An XPath
#' @keywords internal
box_module_base_path <- function() {
  "//SYMBOL_PACKAGE[(text() = 'box' and following-sibling::SYMBOL_FUNCTION_CALL[text() = 'use'])]
  /parent::expr
  /parent::expr[
    ./expr/OP-SLASH
  ]
  "
}

#' Find `box::use` calls for R libraries/packages
#'
#' @details
#' Base XPath to find `box::use` declarations that match the following pattern:
#' \code{
#' box::use(
#'   package,
#' )
#' }
#'
#' @seealso [box_separate_calls_linter()]
#'
#' @return An XPath
#' @keywords internal
box_package_base_path <- function() {
  "//SYMBOL_PACKAGE[(text() = 'box' and following-sibling::SYMBOL_FUNCTION_CALL[text() = 'use'])]
  /parent::expr
  /parent::expr[
    not(./expr/OP-SLASH)
  ]
  "
}

Try the box.linters package in your browser

Any scripts or data that you put into this service are public.

box.linters documentation built on Sept. 11, 2024, 8:20 p.m.