Skip to content

Commit

Permalink
Implement linter tags file compatible lintr 3.0.0 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kolomanski authored Aug 20, 2024
1 parent e5658e4 commit 293a178
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: box.linters
Title: Linters for 'box' Modules
Version: 0.10.1
Version: 0.10.1.9001
Authors@R:
c(
person("Ricardo Rodrigo", "Basa", role = c("aut", "cre"), email = "[email protected]"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# box.linters (development version)

* Implemented linter tags file compatible with `lintr::available_linters()` and
`lintr::available_tags()` functions.

# box.linters 0.10.1

* `box_unused_att_pkg_fun_linter()` allows functions passed into other functions by name without `()`.
Expand Down
16 changes: 16 additions & 0 deletions inst/lintr/linters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
linter,tags
box_alphabetical_calls_linter,best_practices readability
box_func_import_count_linter,best_practices configurable readability configurable
box_mod_fun_exists_linter,default executing
box_pkg_fun_exists_linter,default executing
box_separate_calls_linter,common_mistakes readibility
box_trailing_commas_linter,common_mistakes best_practices configurable
box_universal_import_linter,best_practices robustness efficiency
box_unused_attached_mod_linter,default executing consistency efficiency
box_unused_attached_mod_obj_linter,default executing consistency efficiency
box_unused_attached_pkg_fun_linter,default executing consistency efficiency
box_unused_attached_pkg_linter,default executing consistency efficiency
box_usage_linter,default executing consistency
namespace_function_calls,default correctness configurable
r6_usage_linter,default executing consistency
unused_declared_object_linter,default executing consistency
36 changes: 36 additions & 0 deletions tests/testthat/test-linter_tags.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#'
#' This file tests whether the lintr::available_linters() and lintr::available_tags()
#' functions can read the csv file with linter definitions.
#'
#' lintr expects the package to be already installed. Those tests need to be run
#' using devtools::check(), otherwise will be skipped.
#'
#' Manual checks can also be performed by installing the package and setting the
#' `linters_csv_location` variable to "./inst/lintr/linters.csv", then running
#' tests in the console.
#'
linters_csv_location <- "../../box.linters/lintr/linters.csv"

test_that("lintr::available_linters() reads csv file with linters and tags", {
skip_if(!file.exists(linters_csv_location))

expected_linters <- read.csv(linters_csv_location)
detected_linters <- lintr::available_linters("box.linters")

expect_identical(detected_linters$linter, expected_linters$linter)
expect_identical(detected_linters$tags, strsplit(expected_linters$tags, " "))
})

test_that("lintr::available_tags() reads list of tags for the package", {
skip_if(!file.exists(linters_csv_location))

expected_tags <- read.csv(linters_csv_location)$tags |>
strsplit(" ") |>
unlist() |>
unique() |>
sort()

detected_tags <- lintr::available_tags("box.linters")

expect_identical(detected_tags, expected_tags)
})

0 comments on commit 293a178

Please sign in to comment.