From 193251a25a7a56debd91260091e312cf67394d14 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 25 May 2022 11:08:53 -0500 Subject: [PATCH 1/3] When linting fails, error instead of quitting --- R/methods.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/R/methods.R b/R/methods.R index a8d0a5824..030d36394 100644 --- a/R/methods.R +++ b/R/methods.R @@ -81,13 +81,20 @@ print.lints <- function(x, ...) { lapply(x, print, ...) } - if (isTRUE(settings$error_on_lint)) { - quit("no", 31L, FALSE) # nocov - } } else if (use_rstudio_source_markers) { # Empty lints: clear RStudio source markers rstudio_source_markers(x) } + + if (isTRUE(settings$error_on_lint)) { + stop(sprintf( + ngettext(length(x), + "Linting failed with %i issue", + "Linting failed with %i issues" + ), length(x) + ), call. = FALSE) + } + invisible(x) } From cd8ba01081d74a8a1c5715874991bc0e8a5e8d5c Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 25 May 2022 11:09:05 -0500 Subject: [PATCH 2/3] Default LINTR_ERROR_ON_LINT to true --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 36306691c..448385659 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -230,7 +230,7 @@ settings <- NULL "n71nn28") , 54L - 13L), comment_bot = logical_env("LINTR_COMMENT_BOT") %||% TRUE, - error_on_lint = logical_env("LINTR_ERROR_ON_LINT") %||% FALSE + error_on_lint = logical_env("LINTR_ERROR_ON_LINT") %||% TRUE ) settings <<- list2env(default_settings, parent = emptyenv()) From f1692fe628e9890d41ee1b3a2b797f12af5b671c Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 25 May 2022 14:28:55 -0500 Subject: [PATCH 3/3] Move stop() call back to correct place --- R/methods.R | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/R/methods.R b/R/methods.R index 030d36394..a1bf91abb 100644 --- a/R/methods.R +++ b/R/methods.R @@ -81,19 +81,20 @@ print.lints <- function(x, ...) { lapply(x, print, ...) } + if (isTRUE(settings$error_on_lint)) { + stop(sprintf( + ngettext(length(x), + "Linting failed with %i issue", + "Linting failed with %i issues" + ), length(x) + ), call. = FALSE) + } + } else if (use_rstudio_source_markers) { # Empty lints: clear RStudio source markers rstudio_source_markers(x) } - if (isTRUE(settings$error_on_lint)) { - stop(sprintf( - ngettext(length(x), - "Linting failed with %i issue", - "Linting failed with %i issues" - ), length(x) - ), call. = FALSE) - } invisible(x) }