Skip to content

Commit 344bf4d

Browse files
committed
Rename files + add warn = FALSE
1 parent bfed992 commit 344bf4d

File tree

11 files changed

+9
-5
lines changed

11 files changed

+9
-5
lines changed

R/files-conflicts.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ solve_file_name_conflict <- function(files, regex, dir = ".", extra_msg = NULL,
8585
}
8686
bullets_df <-
8787
rlang::set_names(files) |>
88-
purrr::map(\(x) readLines(x, encoding = "UTF-8")) |>
88+
purrr::map(\(x) readLines(x, encoding = "UTF-8", warn = FALSE)) |>
8989
purrr::map(\(x) tibble::enframe(x, name = "line_number", value = "content")) |>
9090
dplyr::bind_rows(.id = "file")
9191

@@ -145,7 +145,7 @@ get_referenced_files <- function(files) {
145145
# Create a list of genuine referenced files
146146
# TODO Add false positive references
147147
# TODO fs::path and file.path should be handled differently
148-
purrr::map(files, \(x) readLines(x, encoding = "UTF-8")) |>
148+
purrr::map(files, \(x) readLines(x, encoding = "UTF-8", warn = FALSE)) |>
149149
purrr::list_c(ptype = "character") |>
150150
stringr::str_subset(pattern = "\\:\\:dav.+lt|\\:\\:nw_|g.docs_l.n|target-|\\.0pt", negate = TRUE) |> # remove false positive from .md files
151151
stringr::str_subset(pattern = "file.path|fs\\:\\:path\\(|path_package|system.file", negate = TRUE) |> # Exclude fs::path() and file.path from search since handled differently.
File renamed without changes.

R/rename-files.R renamed to R/rename.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ rename_files2 <- function(old,
7575
}
7676

7777
is_git <- !isFALSE(tryCatch(rprojroot::find_root_file(criterion = rprojroot::criteria$is_vcs_root), error = function(e) FALSE))
78+
proj_name <- proj_get2()
7879
if (interactive() && !is_git && !identical(Sys.getenv("TESTTHAT"), "true")) {
7980
cli::cli_warn(c(
8081
"It is better to use this function in a version-controlled repository.",
@@ -91,6 +92,8 @@ rename_files2 <- function(old,
9192
related_files <- fs::dir_ls(regexp = paste0(basename_remove_ext(old), "\\."), recurse = TRUE)
9293
related_files <- fs::path_filter(related_files, "_snaps/|_book/|_files|_freeze|renv/", invert = TRUE)
9394
related_files <- setdiff(related_files, old)
95+
# remove project name from conflicts.
96+
related_files <- stringr::str_subset(related_files, proj_name, negate = TRUE)
9497
if (length(related_files) > 0) {
9598
# maybe would need to normalize path.
9699
cli::cli_warn(c(
@@ -359,7 +362,7 @@ hint_acceptable_renaming <- function(old, new, overwrite) {
359362
))
360363
return(FALSE)
361364
}
362-
# r-lib/cli#683
365+
# Delete when fixed r-lib/cli#683
363366
old_chr <- as.character(old)
364367
new_chr <- as.character(new)
365368

R/use-todo.R renamed to R/todo.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ complete_todo <- function(line, file, regexp, rm_line = NULL) {
8787
}
8888
warn_change_of_line <- FALSE
8989

90-
file_content <- readLines(file, encoding = "UTF-8")
90+
file_content <- readLines(file, encoding = "UTF-8", warn = FALSE)
9191
line_content <- file_content[line]
9292

9393
# Special case for issues (probably need to opt out at some point)

TODO.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424
# TODO [check_referenced_files] doesn't check for {.file R/file.R}
2525
# TODO explain rationale behind `work_only`. Suggest to transform to TODO if this item is no longer critical. `work_only` goal is to show you exactly where you need to do work
2626
# TODO [outline] Show function call if exported + not internal + bonus if has family tagf
27+
# TODO rename_files should be less noisy about project name file
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)