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

Clean lints in utils.R #342

Merged
merged 5 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ VignetteBuilder:
knitr
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.2.3
RoxygenNote: 7.2.3.9000
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/Needs/website:
Expand Down
19 changes: 10 additions & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
cran_version <- lapply(pkgs[pkg_deps, "Version"], package_version)
local_version <- lapply(pkg_deps, utils::packageVersion)

behind <- mapply(">", cran_version, local_version)
behind <- Map(">", cran_version, local_version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Map() return a vector or a list by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it always returns a list, and doesn't try to simplify the results.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But mapply() returns a vector, no? So I'm not sure you need to unlist here.


data.frame(
package = pkg_deps,
cran = sapply(cran_version, as.character),
local = sapply(local_version, as.character),
cran = vapply(cran_version, as.character, FUN.VALUE = character(1L)),
local = vapply(local_version, as.character, FUN.VALUE = character(1L)),
behind = behind,
stringsAsFactors = FALSE
)
Expand Down Expand Up @@ -53,8 +53,8 @@

out <- data.frame(
package = easystats_on_cran,
cran = sapply(cran_version, as.character),
local = sapply(local_version, as.character),
cran = vapply(cran_version, as.character, FUN.VALUE = character(1L)),
local = vapply(local_version, as.character, FUN.VALUE = character(1L)),
behind = behind,
stringsAsFactors = FALSE,
row.names = NULL
Expand All @@ -71,7 +71,7 @@
out <- data.frame(
package = easystats_on_cran,
cran = NA,
local = sapply(local_version, as.character),
local = vapply(local_version, as.character, FUN.VALUE = character(1L)),
behind = FALSE,
stringsAsFactors = FALSE,
row.names = NULL
Expand All @@ -85,7 +85,7 @@
.add_easystats_dev_pkgs <- function(out, easystats_not_on_cran) {
if (length(easystats_not_on_cran) > 0L) {
# check if any dev-version is actually installed
easystats_not_on_cran <- sapply(
easystats_not_on_cran <- vapply(
easystats_not_on_cran,
function(i) {
p <- try(find.package(i, verbose = FALSE, quiet = TRUE))
Expand All @@ -94,7 +94,8 @@
} else {
""
}
}
},
FUN.VALUE = character(1L)
)

# remove empty
Expand All @@ -109,7 +110,7 @@
data.frame(
package = easystats_not_on_cran,
cran = NA,
local = sapply(local_version_dev, as.character),
local = vapply(local_version_dev, as.character, FUN.VALUE = character(1L)),
behind = FALSE,
stringsAsFactors = FALSE,
row.names = NULL
Expand Down