Skip to content

Commit 427b258

Browse files
committed
Add call. = FALSE to warning() calls
1 parent 0b2e34d commit 427b258

File tree

10 files changed

+30
-14
lines changed

10 files changed

+30
-14
lines changed

R/backport_linter.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ normalize_r_version <- function(r_version) {
109109
stop("`r_version` must be a R version number, returned by R_system_version(), or a string.", call. = FALSE)
110110
}
111111
if (r_version < "3.0.0") {
112-
warning("It is not recommended to depend on an R version older than 3.0.0. Resetting 'r_version' to 3.0.0.")
112+
warning(
113+
"It is not recommended to depend on an R version older than 3.0.0. Resetting 'r_version' to 3.0.0.",
114+
call. = FALSE
115+
)
113116
r_version <- R_system_version("3.0.0")
114117
}
115118
r_version

R/cache.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ load_cache <- function(file, path = NULL) {
5555
error = function(e) {
5656
warning(
5757
"Could not load cache file '", file, "':\n",
58-
conditionMessage(e)
58+
conditionMessage(e),
59+
call. = FALSE
5960
)
6061
}
6162
)

R/exclude.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ add_exclusions <- function(exclusions, lines, linters_string, exclude_linter_sep
204204
warning(
205205
"Could not find linter", if (length(bad) > 1L) "s" else "", " named ",
206206
glue_collapse(sQuote(bad), sep = ", ", last = " and "),
207-
" in the list of active linters. Make sure the linter is uniquely identified by the given name or prefix."
207+
" in the list of active linters. Make sure the linter is uniquely identified by the given name or prefix.",
208+
call. = FALSE
208209
)
209210
}
210211
excluded_linters[matched] <- linter_names[idxs[matched]]

R/extract.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ get_knitr_pattern <- function(filename, lines) {
5151
("knitr" %:::% "detect_pattern")(lines, tolower(("knitr" %:::% "file_ext")(filename))),
5252
warning = function(cond) {
5353
if (!grepl("invalid UTF-8", conditionMessage(cond), fixed = TRUE)) {
54-
warning(cond)
54+
warning(cond, call. = FALSE)
5555
}
5656
invokeRestart("muffleWarning")
5757
}

R/lint.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ lint_package <- function(path = ".", ...,
238238
pkg_path <- find_package(path)
239239

240240
if (is.null(pkg_path)) {
241-
warning(sprintf("Didn't find any R package searching upwards from '%s'.", normalizePath(path)))
241+
warning(
242+
sprintf("Didn't find any R package searching upwards from '%s'.", normalizePath(path)),
243+
call. = FALSE
244+
)
242245
return(NULL)
243246
}
244247

R/linter_tags.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ validate_linter_db <- function(available, package) {
121121
"`linters.csv` must contain the columns 'linter' and 'tags'.\nPackage '",
122122
package, "' is missing ",
123123
paste0("'", setdiff(c("linter", "tags"), names(available)), "'", collapse = " and "),
124-
"."
124+
".",
125+
call. = FALSE
125126
)
126127
return(FALSE)
127128
}

R/object_usage_linter.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ parse_check_usage <- function(expression,
215215
# TODO (AshesITR): Remove this in the future, if no bugs arise from this safeguard
216216
warning(
217217
"Possible bug in lintr: Couldn't parse usage message ", sQuote(vals[is_missing][[1L]]), ". ",
218-
"Ignoring ", sum(is_missing), " usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues."
218+
"Ignoring ", sum(is_missing), " usage warnings. Please report an issue at https://github.com/r-lib/lintr/issues.",
219+
call. = FALSE
219220
)
220221
}
221222
# nocov end

R/settings.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ read_config_file <- function(config_file) {
124124
warning = function(w) {
125125
warning(
126126
"Warning from config setting '", setting, "' in '", format(conditionCall(w)), "':\n",
127-
" ", conditionMessage(w)
127+
" ", conditionMessage(w),
128+
call. = FALSE
128129
)
129130
invokeRestart("muffleWarning")
130131
}
@@ -152,7 +153,10 @@ read_config_file <- function(config_file) {
152153
validate_config_file <- function(config, config_file, defaults) {
153154
matched <- names(config) %in% names(defaults)
154155
if (!all(matched)) {
155-
warning("Found unused settings in config '", config_file, "': ", toString(names(config)[!matched]))
156+
warning(
157+
"Found unused settings in config '", config_file, "': ", toString(names(config)[!matched]),
158+
call. = FALSE
159+
)
156160
}
157161

158162
validate_regex(config,

R/with.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ modify_defaults <- function(defaults, ...) {
4747
is_are <- if (length(bad_nms) > 1L) "are" else "is"
4848
warning(
4949
"Trying to remove ", glue_collapse(sQuote(bad_nms), sep = ", ", last = " and "),
50-
", which ", is_are, " not in `defaults`."
50+
", which ", is_are, " not in `defaults`.",
51+
call. = FALSE
5152
)
5253
}
5354

@@ -180,7 +181,8 @@ linters_with_defaults <- function(..., defaults = default_linters) {
180181
if (missing(defaults) && "default" %in% names(dots)) {
181182
warning(
182183
"'default' is not an argument to linters_with_defaults(). Did you mean 'defaults'? ",
183-
"This warning will be removed when with_defaults() is fully deprecated."
184+
"This warning will be removed when with_defaults() is fully deprecated.",
185+
call. = FALSE
184186
)
185187
defaults <- dots$default
186188
nms <- names2(dots)

R/xml_nodes_to_lints.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ xml_nodes_to_lints <- function(xml, source_expression, lint_message,
6363
line1 <- xml_attr(xml, "line1")
6464
col1 <- xp_find_location(xml, range_start_xpath)
6565
if (is.na(col1)) {
66-
warning("Could not find range start for lint. Defaulting to start of line.")
66+
warning("Could not find range start for lint. Defaulting to start of line.", call. = FALSE)
6767
col1 <- 1L
6868
}
6969

@@ -73,7 +73,7 @@ xml_nodes_to_lints <- function(xml, source_expression, lint_message,
7373
if (xml_attr(xml, "line2") == line1) {
7474
col2 <- xp_find_location(xml, range_end_xpath)
7575
if (is.na(col2)) {
76-
warning("Could not find range end for lint. Defaulting to width 1.")
76+
warning("Could not find range end for lint. Defaulting to width 1.", call. = FALSE)
7777
col2 <- col1
7878
}
7979
} else {
@@ -82,7 +82,7 @@ xml_nodes_to_lints <- function(xml, source_expression, lint_message,
8282

8383
column_number <- xp_find_location(xml, column_number_xpath)
8484
if (is.na(column_number)) {
85-
warning("Could not find location for lint. Defaulting to start of range.")
85+
warning("Could not find location for lint. Defaulting to start of range.", call. = FALSE)
8686
column_number <- col1
8787
}
8888

0 commit comments

Comments
 (0)