diff --git a/NAMESPACE b/NAMESPACE index 6b5c46937..c02307cf3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -180,13 +180,10 @@ importFrom(stats,na.omit) importFrom(tools,R_user_dir) importFrom(utils,capture.output) importFrom(utils,getParseData) -importFrom(utils,getTxtProgressBar) importFrom(utils,globalVariables) importFrom(utils,head) importFrom(utils,relist) -importFrom(utils,setTxtProgressBar) importFrom(utils,tail) -importFrom(utils,txtProgressBar) importFrom(xml2,as_list) importFrom(xml2,xml_attr) importFrom(xml2,xml_children) diff --git a/NEWS.md b/NEWS.md index 68ef13f8d..f1d9a44b7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -87,7 +87,7 @@ ## Notes -* All user-facing messages are now prepared using the `{cli}` package (#2418, @IndrajeetPatil). All messages have been reviewed and updated to be more informative and consistent. +* All user-facing messages (including progress bar) are now prepared using the `{cli}` package (#2418 and #2641, @IndrajeetPatil). All messages have been reviewed and updated to be more informative and consistent. * {lintr} now depends on R version 4.0.0. It already does so implicitly due to recursive upstream dependencies requiring this version; we've simply made that dependency explicit and up-front (#2569, @MichaelChirico). # lintr 3.1.2 diff --git a/R/lint.R b/R/lint.R index 042fbeaca..d9e135692 100644 --- a/R/lint.R +++ b/R/lint.R @@ -182,20 +182,11 @@ lint_dir <- function(path = ".", ..., return(lints) } - pb <- if (isTRUE(show_progress)) { - txtProgressBar(max = length(files), style = 3L) - } - lints <- flatten_lints(lapply( - files, - function(file) { - maybe_report_progress(pb) - lint(file, ..., parse_settings = FALSE, exclusions = exclusions) - } + cli::cli_progress_along(files, name = "Running linters"), + function(idx) lint(files[idx], ..., parse_settings = FALSE, exclusions = exclusions) )) - if (!is.null(pb)) close(pb) - lints <- reorder_lints(lints) if (relative_path) { @@ -688,13 +679,6 @@ has_positional_logical <- function(dots) { !nzchar(names2(dots)[1L]) } -maybe_report_progress <- function(pb) { - if (is.null(pb)) { - return(invisible()) - } - setTxtProgressBar(pb, getTxtProgressBar(pb) + 1L) -} - maybe_append_error_lint <- function(lints, error, lint_cache, filename) { if (inherits(error, "lint")) { error$linter <- "error" diff --git a/R/lintr-package.R b/R/lintr-package.R index 70f8d0d11..ff9fba37d 100644 --- a/R/lintr-package.R +++ b/R/lintr-package.R @@ -13,8 +13,7 @@ #' @importFrom rex rex regex re_matches re_substitutes character_class #' @importFrom stats na.omit #' @importFrom tools R_user_dir -#' @importFrom utils capture.output getParseData getTxtProgressBar globalVariables head relist -#' setTxtProgressBar tail txtProgressBar +#' @importFrom utils capture.output getParseData globalVariables head relist tail #' @importFrom xml2 as_list #' xml_attr xml_children xml_find_all xml_find_chr xml_find_lgl xml_find_num xml_find_first xml_name xml_text ## lintr namespace: end diff --git a/tests/testthat/test-lint_dir.R b/tests/testthat/test-lint_dir.R index 6da4b81bb..da6dd824c 100644 --- a/tests/testthat/test-lint_dir.R +++ b/tests/testthat/test-lint_dir.R @@ -10,12 +10,6 @@ test_that("lint all files in a directory", { expect_s3_class(lints, "lints") expect_identical(sort(linted_files), sort(files)) - - expect_output( - lint_dir(the_dir, parse_settings = FALSE, show_progress = TRUE), - "======", - fixed = TRUE - ) }) test_that("lint all relevant directories in a package", {