-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededro-hackathon-2025
Description
There is some code that is mainly intended for testing and running examples.
rJavaEnv/R/java_quick_install.R
Lines 26 to 39 in 1de37c0
| if (temp_dir) { | |
| temp_dir <- tempdir() | |
| setwd(temp_dir) | |
| if (!dir.exists("rJavaEnv_cache")) { | |
| dir.create("rJavaEnv_cache", recursive = TRUE) | |
| } | |
| cache_path <- file.path(temp_dir, "rJavaEnv_cache") | |
| if (!dir.exists("rJavaEnv_project")) { | |
| dir.create("rJavaEnv_project", recursive = TRUE) | |
| } | |
| project_path <- file.path(temp_dir, "rJavaEnv_project") | |
| } else { | |
| cache_path <- getOption("rJavaEnv.cache_path") | |
| } |
and
Lines 33 to 41 in 1de37c0
| # override cache_path if temp_dir is set to TRUE | |
| if (temp_dir) { | |
| temp_dir <- tempdir() | |
| setwd(temp_dir) | |
| if (!dir.exists("rJavaEnv_cache")) { | |
| dir.create("rJavaEnv_cache", recursive = TRUE) | |
| } | |
| cache_path <- file.path(temp_dir, "rJavaEnv_cache") | |
| } |
After running goodpractice::gp("rJavaEnv") I got a suggestion:
✖ avoid calling setwd(), it changes the global environment. If you need it, consider using on.exit() to restore the
working directory.
R/java_download.R:36:5
R/java_quick_install.R:28:5
vignettes/rJavaEnv-step-by-step.qmd:27:1
vignettes/rJavaEnv.qmd:48:1
So even though this code is not critical for the functioning of the package, it would indeed be nice to stick to the good practices and add the appropriate on.exit() call to restore the working directory.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededro-hackathon-2025