Skip to content

Commit

Permalink
Improve code style
Browse files Browse the repository at this point in the history
  • Loading branch information
GegznaV committed Aug 26, 2023
1 parent 811cd1a commit ce443a8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
6 changes: 4 additions & 2 deletions R/helpers--make_unique_obj_names.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
make_unique_obj_names <- function(names, prefix = "", suffix = "",
list_of_choices = objects(all.names = TRUE,
envir = .GlobalEnv),
list_of_choices = objects(
all.names = TRUE,
envir = .GlobalEnv
),
all_numbered = TRUE) {
if (length(names) == 0) {
return(NULL)
Expand Down
6 changes: 3 additions & 3 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ ui_msg_restart_rstudio <- function() {
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# str_glue_eval ==============================================================
str_glue_eval <- function(..., envir = parent.frame(), .sep = "",
.open = "{", .close = "}", envir_eval = envir, envir_glue = envir) {

str_glue_eval <- function(
..., envir = parent.frame(), .sep = "",
.open = "{", .close = "}", envir_eval = envir, envir_glue = envir) {
commands_as_text <- glue::glue(...,
.envir = envir_glue,
.open = .open,
Expand Down
11 changes: 5 additions & 6 deletions R/packages--find.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ list_pkgs_used_in_dir_code <- function(path = ".", regexp = "(?i)[.](rmd|r)$", .
# TODO: ignore code in comments
list_pkgs_used_in_files <- function(files) {
files %>%
purrr::map(~readr::read_file(.)) %>%
purrr::map(~ readr::read_file(.)) %>%
stringr::str_extract_all(
paste0(
"(?<=(library|require|require2)\\()(.*?)(?=\\))|", # library(dplyr)
Expand All @@ -74,10 +74,10 @@ list_pkgs_used_in_files <- function(files) {

list_pkgs_used_in_files_code <- function(files) {
files %>%
purrr::map(~readr::read_file(.)) %>%
purrr::map(~ readr::read_file(.)) %>%
stringr::str_extract_all(
paste0(
"(library|require|require2)\\((.*?)\\)|", # library(dplyr)
"(library|require|require2)\\((.*?)\\)|", # library(dplyr)
"(\\s|\\n|\\(|\\{|\\[)[a-zA-Z0-9.]*?( )*:{2,3}[a-zA-Z0-9._]*|", # dplyr::select
"package\\s*=\\s*(\"|')[a-zA-Z0-9.]*?(\"|')" # data(package = "dplyr")
)
Expand All @@ -90,7 +90,6 @@ list_pkgs_used_in_files_code <- function(files) {
get_pkg_dependencies <- function(pkg) {
pkg <- stringr::str_replace(pkg, "[.]", "[.]")
desc::desc_get_deps(fs::dir_ls(.libPaths(), regexp = glue::glue("/{pkg}$"))) %>%
dplyr::filter(.data$type %in% c("Depends", "Imports")) %>%
dplyr::pull(.data$package)
dplyr::filter(.data$type %in% c("Depends", "Imports")) %>%
dplyr::pull(.data$package)
}

5 changes: 2 additions & 3 deletions R/restart_reload.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @concept utilities
#'
rstudio_restart_r <- function() {
if (rstudioapi::isAvailable(version_needed = "1.2.1261") ) {
if (rstudioapi::isAvailable(version_needed = "1.2.1261")) {
invisible(rstudioapi::executeCommand("restartR", quiet = TRUE))
}
}
Expand All @@ -19,7 +19,7 @@ rstudio_restart_r <- function() {
#' @export
#' @concept utilities
rstudio_reload_ui <- function() {
if (rstudioapi::isAvailable(version_needed = "1.2.1261") ) {
if (rstudioapi::isAvailable(version_needed = "1.2.1261")) {
invisible(rstudioapi::executeCommand("reloadUi", quiet = TRUE))
}
}
Expand All @@ -35,4 +35,3 @@ restart_r <- function() {
restart_rstudio <- function() {
rstudio_restart_r()
}

14 changes: 7 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Options:
```{r README-7a, eval=FALSE}
bio::check_installed_programs()
## ✔ Program R (4.3.1) is installed (recommended >= 4.3.1).
## ✖ Program RStudio is not installed or is not running.
## ✖ Program RStudio is not installed or is not running.
## ✔ Tool Quarto (1.4.268) is installed (recommended >= 1.3.336).
## ✔ Tool Rtools is installed.
```
Expand Down Expand Up @@ -157,13 +157,13 @@ cat(res)

```{r README-8a, eval=FALSE, paged.print=FALSE}
bio::check_packages_by_topic("mini")
## ℹ Reading list 'mini'
## ℹ Reading list 'mini'
## ✔ Minimal required versions of all 19 packages (from list 'mini') are already installed.
```

```{r README-8b, eval=FALSE, paged.print=FALSE}
bio::check_packages_by_topic("mini", include = "newer_on_cran")
## ℹ Reading list 'mini'
## ℹ Reading list 'mini'
## ✔ Minimal required versions of all 19 packages (from list 'mini') are already installed.
## ℹ Note: 1 package has newer version on CRAN.
```
Expand All @@ -186,9 +186,9 @@ Check if there are updates for **bio** or its dependency packages.
```{r README-3b, eval=FALSE, paged.print=FALSE}
bio::check_updates_pkg_bio()
## ℹ Analyzing dependencies of package bio
##
##
## [... truncated ...]
##
##
## ✔ Minimal required versions of all 26 packages (from list 'bio') are already installed.
```

Expand Down Expand Up @@ -221,7 +221,7 @@ bio::rstudio_install_spellcheck_dictionaries()
Install improved Lithuanian dictionary.
```{r eval=FALSE}
bio::rstudio_install_spellcheck_dictionary_lt()
## ✔ lt_LT dictionary installed.
## ✔ lt_LT dictionary installed.
## 'C:/Users/ViG/AppData/Roaming/RStudio/dictionaries/languages-system/lt_LT.dic'
```

Expand Down Expand Up @@ -348,7 +348,7 @@ snippets::install_snippets_from_package("snippets", backup = TRUE)
## 'C:/Users/User/AppData/Roaming/RStudio/snippets/markdown.snippets'
## ✔ File with r snippets was updated:
## 'C:/Users/User/AppData/Roaming/RStudio/snippets/r.snippets'
##
##
## ℹ You will be able to use the snippets after RStudio is closed and reopened.
```

Expand Down

0 comments on commit ce443a8

Please sign in to comment.