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

Use .data pronoun to prevent global variable warning in R CMD check #328

Merged
merged 4 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion R/cran-compliance.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@

if (is.null(lib_name)) {
lib_name <- as_valid_rust_name(pkg_name(path))
} else if (length(lib_name) > 1) {
cli::cli_abort(
"{.arg lib_name} must be a character scalar",
class = "rextendr_error"

Check warning on line 51 in R/cran-compliance.R

View check run for this annotation

Codecov / codecov/patch

R/cran-compliance.R#L48-L51

Added lines #L48 - L51 were not covered by tests
)
}

Expand Down Expand Up @@ -94,11 +94,11 @@

# vendor directory should be ignored by git and R CMD build
if (!rlang::is_installed("usethis")) {
cli::cli_inform(
c(
"!" = "Add {.code ^src/rust/vendor$} to your {.file .Rbuildignore}",
"!" = "Add {.code ^src/rust/vendor$} to your {.file .gitignore}",
"i" = "Install {.pkg usethis} to have this done automatically."

Check warning on line 101 in R/cran-compliance.R

View check run for this annotation

Codecov / codecov/patch

R/cran-compliance.R#L97-L101

Added lines #L97 - L101 were not covered by tests
)
)
} else {
Expand Down Expand Up @@ -130,9 +130,9 @@

# if `src/rust` does not exist error
if (!dir.exists(src_dir)) {
cli::cli_abort(
c("{.path src/rust} cannot be found", "i" = "Did you run {.fn use_extendr}?"),
class = "rextendr_error"

Check warning on line 135 in R/cran-compliance.R

View check run for this annotation

Codecov / codecov/patch

R/cran-compliance.R#L133-L135

Added lines #L133 - L135 were not covered by tests
)
}

Expand All @@ -153,9 +153,9 @@
})

if (update_res[["status"]] != 0) {
cli::cli_abort(
"{.file Cargo.lock} could not be created using {.code cargo generate-lockfile}",
class = "rextendr_error"

Check warning on line 158 in R/cran-compliance.R

View check run for this annotation

Codecov / codecov/patch

R/cran-compliance.R#L156-L158

Added lines #L156 - L158 were not covered by tests
)
}
}
Expand All @@ -175,9 +175,9 @@
})

if (vendor_res[["status"]] != 0) {
cli::cli_abort(
"{.code cargo vendor} failed",
class = "rextendr_error"

Check warning on line 180 in R/cran-compliance.R

View check run for this annotation

Codecov / codecov/patch

R/cran-compliance.R#L178-L180

Added lines #L178 - L180 were not covered by tests
)
}

Expand All @@ -191,7 +191,7 @@
rlang::set_names(c("source", "crate", "version")) %>%
dplyr::filter(!is.na(source)) %>%
dplyr::select(-source) %>%
dplyr::arrange(crate) # nolint: object_usage_linter
dplyr::arrange(.data$crate) # nolint: object_usage_linter
JosiahParry marked this conversation as resolved.
Show resolved Hide resolved

# capture vendor-config.toml content
config_toml <- vendor_res[["stdout"]] %>%
Expand All @@ -213,9 +213,9 @@
})

if (compress_res[["status"]] != 0) {
cli::cli_abort(
"Folder {.path vendor} could not be compressed",
class = "rextendr_error"

Check warning on line 218 in R/cran-compliance.R

View check run for this annotation

Codecov / codecov/patch

R/cran-compliance.R#L216-L218

Added lines #L216 - L218 were not covered by tests
)
}

Expand Down
26 changes: 13 additions & 13 deletions tests/testthat/_snaps/use_cran_defaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,18 @@
---

Code
package_versions
package_versions["crate"]
Output
# A tibble: 9 x 2
crate version
<chr> <chr>
1 extendr-api 0.6.0
2 extendr-macros 0.6.0
3 libR-sys 0.6.0
4 once_cell 1.19.0
5 paste 1.0.14
6 proc-macro2 1.0.70
7 quote 1.0.33
8 syn 2.0.42
9 unicode-ident 1.0.12
# A tibble: 9 x 1
crate
<chr>
1 extendr-api
2 extendr-macros
3 libR-sys
4 once_cell
5 paste
6 proc-macro2
7 quote
8 syn
9 unicode-ident

2 changes: 1 addition & 1 deletion tests/testthat/test-use_cran_defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ test_that("vendor_pkgs() vendors dependencies", {

package_versions <- vendor_pkgs(path, quiet = TRUE)
expect_snapshot(cat_file("src", "rust", "vendor-config.toml"))
expect_snapshot(package_versions)
JosiahParry marked this conversation as resolved.
Show resolved Hide resolved
expect_snapshot(package_versions["crate"])
expect_true(file.exists(file.path("src", "rust", "vendor.tar.xz")))
})
Loading