Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customize lengths_linter for data.table usage #6100

Merged
merged 3 commits into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .ci/linters/dt_lengths_linter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This is lintr::lengths_linter(), but including 'vapply_1i()' which is more common internally in data.table
# alternatively, this could be defined with something like
# dt_lengths_linter <- lintr::lengths_linter()
# local({ # to remove 'e'
# e <- environment(dt_lengths_linter)
# e$function_names <- c(evalq(function_names, e), "vapply_1i")
# })
# but that feels more fragile than this.
dt_lengths_linter <- lintr::make_linter_from_function_xpath(
function_names = c("sapply", "vapply", "vapply_1i", "map_int", "map_dbl"),
xpath = "parent::expr/parent::expr[expr/SYMBOL[text() = 'length']]",
lint_message = "Use lengths() to find the length of each element in a list."
)
Loading