Skip to content

Commit 9c42e52

Browse files
committed
Report conflicts with lazy loaded datasets
Fixes #54
1 parent e2bfc11 commit 9c42e52

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# conflicted (development version)
22

3+
* Conflicted involing lazy loaded datasets are now reported (#54).
4+
35
* Conflicts involving a `standardGeneric` are no longer reported (#47).
46

57
* Conflicts involving the superset principle are better handled: if there is

R/package.R

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ pkg_ls <- function(pkg) {
1717

1818
names <- intersect(exports, env_names(ns))
1919
int <- grepl("^.__", names)
20-
names[!int]
20+
c(names[!int], pkg_data(pkg))
2121
}
2222

23-
pkg_get <- function(pkg, name) {
24-
get(name, envir = ns_env(pkg), inherits = FALSE)
25-
}
26-
27-
# Not currently used because pkg_get() can't find it, and it seems unlikely
28-
# to be a common source of conflicts
2923
pkg_data <- function(x) {
3024
ns <- ns_env(x)
3125
lazy_data <- .getNamespaceInfo(ns, "lazydata")

R/utils.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ map2 <- function(.x, .y, .f, ...) {
4141
}
4242

4343
unique_obj <- function(name, pkgs) {
44-
objs <- lapply(pkgs, pkg_get, name)
44+
objs <- lapply(pkgs, getExportedValue, name)
4545
names(objs) <- pkgs
4646

4747
pkgs[!duplicated(objs)]

tests/testthat/data/DESCRIPTION

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Package: data
2+
Title: What the Package Does (One Line, Title Case)
3+
Version: 0.0.0.9000
4+
Authors@R: c(
5+
person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")),
6+
person("RStudio", role = c("cph", "fnd"))
7+
)
8+
Description: What the package does (one paragraph).
9+
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
10+
license
11+
Encoding: UTF-8
12+
Roxygen: list(markdown = TRUE)
13+
RoxygenNote: 7.1.2
14+
Depends:
15+
R (>= 2.10)
16+
LazyData: true

tests/testthat/data/NAMESPACE

Whitespace-only changes.

tests/testthat/data/data/mtcars.rda

89 Bytes
Binary file not shown.

tests/testthat/test-find.R

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ test_that("functions aren't conflicts with non-functions", {
2929
expect_equal(function_lookup("mean", c("base", "funmatch")), character())
3030
})
3131

32+
test_that("can find conflicts with data", {
33+
pkgload::load_all(test_path("data"))
34+
on.exit(pkgload::unload("data"))
35+
36+
expect_named(conflict_scout(c("datasets", "data")), "mtcars")
37+
})
38+
3239
# moved functions ----------------------------------------------------
3340

3441
test_that(".Deprecated call contains function name", {

0 commit comments

Comments
 (0)