Skip to content

Commit

Permalink
correct todos naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarbone committed Apr 6, 2021
1 parent 48cd573 commit 2b24c24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# development

* corrects use of `...` in `todos()`

# jordan 0.1.2

## Changes
Expand Down
11 changes: 3 additions & 8 deletions R/todo.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
#' @export

todos <- function(pattern = NULL, ...) {
# fs::dir_ls() would be a lot quicker but would be a new dependency
files <- list.files(pattern = "\\.[Rr]$", recursive = TRUE)
file_list <- lapply(files, readLines, warn = FALSE)
finds <- lapply(file_list,
function(x) {
ind <- grep(pattern = "[#]\\s+TODO[:]?\\s+", x = x)
quick_df(list(ind = ind, todo = x[ind]))
})

names(finds) <- files
ind <- vap_lgl(finds, function(x) nrow(x) > 0)
finds <- finds[ind]

if (!is.null(pattern)) {
finds <- grep(pattern, finds, value = TRUE, ...)
finds <- finds[grep(pattern, finds, value = FALSE, ...)]
}

if (identical(finds, list())) {
message("No todos found")
return(invisible(NULL))
}

names(finds) <- files[ind]
out <- cbind(rep(names(finds), vap_int(finds, nrow)), Reduce(rbind, finds))
names(out) <- c("file", "line", "todo")
out <- out[, c("line", "file", "todo")]
Expand Down Expand Up @@ -82,8 +82,3 @@ print.todos_df <- function(x, ...) {

invisible(x)
}

# undebug(print.todos_df)

cat0 <- function(...) cat(..., sep = "")
catln <- function(...) cat(..., sep = "\n")

0 comments on commit 2b24c24

Please sign in to comment.