Skip to content

Commit

Permalink
remove lint
Browse files Browse the repository at this point in the history
  • Loading branch information
radbasa committed Jan 11, 2024
1 parent a7222ef commit d64a807
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions R/linter_box_function_import_count_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
#' text = "box::use(package[one, two, three, four, five, six, ])",
#' linters = box_func_import_count_linter()
#' )
#'
#'
#' lintr::lint(
#' text = "box::use(package[one, two, three, four, ])",
#' linters = box_func_import_count_linter(3)
#' )
#'
#'
#' # okay
#' lintr::lint(
#' text = "box::use(package[one, two, three, four, five, ])",
#' linters = box_func_import_count_linter()
#' )
#'
#'
#' lintr::lint(
#' text = "box::use(package[one, two, three, ])",
#' linters = box_func_import_count_linter(3)
#' )
#'
#'
#' @export
box_func_import_count_linter <- function(max = 5L) {
xpath <- glue::glue("//SYMBOL_PACKAGE[
Expand All @@ -44,18 +44,18 @@ box_func_import_count_linter <- function(max = 5L) {
) > {max}
]
/parent::expr")

lint_message <- glue::glue("Limit the function imports to a max of {max}.")

lintr::Linter(function(source_expression) {
if (!lintr::is_lint_level(source_expression, "file")) {
return(list())
}

xml <- source_expression$full_xml_parsed_content

bad_expr <- xml2::xml_find_all(xml, xpath)

lintr::xml_nodes_to_lints(
bad_expr,
source_expression = source_expression,
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-linter_box_function_import_count_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ lint_message <- function(max = 5L) {

test_that("box_func_import_count_linter skips allowed function count.", {
linter <- box_func_import_count_linter()

lintr::expect_lint(five_function_imports, NULL, )
lintr::expect_lint(five_function_imports_inline, NULL, linter)
})

test_that("box_func_import_count_linter skips allowed function count supplied max", {
linter <- box_func_import_count_linter(max = 3)

lintr::expect_lint(three_function_imports, NULL, )
lintr::expect_lint(three_function_imports_inline, NULL, linter)
})
Expand All @@ -61,7 +61,7 @@ test_that("box_func_import_count_linter blocks function imports more than max",
max <- 5
linter <- box_func_import_count_linter(max = max)
lint_msg <- lint_message(max)

lintr::expect_lint(six_function_imports, list(message = lint_msg), linter)
lintr::expect_lint(six_function_imports_inline, list(message = lint_msg), linter)
})

0 comments on commit d64a807

Please sign in to comment.