Skip to content

Commit

Permalink
vectorization+metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Nov 19, 2023
1 parent 7d18026 commit 30c4743
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/test-object_overwrite_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,31 @@ test_that("shorthand lambda is detected", {
test_that("allow_names= works to ignore certain symbols", {
expect_lint("function() data <- 1", NULL, object_overwrite_linter(allow_names = "data"))
})

test_that("lints vectorize", {
lines <- trim_some("{
foo <- function() {
data <- 1
var <- 2
}
bar <- function(data) {
data <- data + 3
sum <- 4
}
}")
expect_lint(
lines,
list(
list(rex::rex("'data' is an exported object from package 'utils'."), line_number = 3L),
list(rex::rex("'var' is an exported object from package 'stats'."), line_number = 4L),
list(rex::rex("'sum' is an exported object from package 'base'."), line_number = 8L)
),
object_overwrite_linter()
)

expect_lint(
lines,
list(rex::rex("'var' is an exported object from package 'stats'."), line_number = 4L),
object_overwrite_linter(packages = c("stats", "base"), allow_names = "sum")
)
})

0 comments on commit 30c4743

Please sign in to comment.