Skip to content

Commit 16d2510

Browse files
Merge pull request #1122 from olivroy/error-links
Various code / tests updates
2 parents fdb7580 + 28b5d06 commit 16d2510

15 files changed

+22
-27
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ importFrom(purrr,pmap)
4848
importFrom(purrr,pwalk)
4949
importFrom(rlang,"%||%")
5050
importFrom(rlang,abort)
51+
importFrom(rlang,check_installed)
5152
importFrom(rlang,is_installed)
5253
importFrom(rlang,seq2)
5354
importFrom(rlang,set_names)

R/communicate.R

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,3 @@ communicate_summary <- function(changed, ruler_width) {
3939
cli::cat_rule(width = max(40L, ruler_width))
4040
}
4141
}
42-
43-
44-
assert_data.tree_installation <- function() {
45-
if (!is_installed("data.tree")) {
46-
abort("The package data.tree needs to be installed for this functionality.")
47-
}
48-
}

R/nested-to-tree.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ create_tree_from_pd_with_default_style_attributes <- function(pd,
4747
#' }
4848
#' @keywords internal
4949
create_node_from_nested_root <- function(pd_nested, structure_only) {
50-
assert_data.tree_installation()
50+
check_installed("data.tree")
5151
name <- if (structure_only) {
5252
"Hierarchical structure"
5353
} else {

R/parse.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ ensure_correct_txt <- function(pd, text) {
158158

159159
if (!lines_and_cols_match(new_text)) {
160160
abort(paste(
161-
"Error in styler:::ensure_correct_txt().",
162-
"Please file an issue on GitHub (https://github.com/r-lib/styler/issues)"
163-
))
161+
"Error in styler:::ensure_correct_txt()."
162+
), .internal = TRUE)
164163
}
165164
names_to_keep <- setdiff(
166165
names(new_text),

R/set-assert-args.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set_arg_write_tree <- function(write_tree) {
99
if (is.na(write_tree)) {
1010
write_tree <- is_installed("data.tree")
1111
} else if (write_tree) {
12-
assert_data.tree_installation()
12+
check_installed("data.tree")
1313
}
1414
write_tree
1515
}

R/styler-package.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
#' @importFrom magrittr "%>%"
2424
#' @importFrom purrr compact partial flatten flatten_int flatten_chr
2525
#' @importFrom purrr map map_lgl map_int map_chr map2 map2_chr map_at pmap pwalk
26-
#' @importFrom rlang abort warn seq2 is_installed "%||%" set_names
27-
#' @importFrom vctrs vec_rbind
28-
#' @importFrom vctrs vec_slice
29-
#' @importFrom vctrs vec_split
26+
#' @importFrom rlang abort warn seq2 check_installed is_installed "%||%" set_names
27+
#' @importFrom vctrs vec_rbind vec_slice vec_split
3028
## usethis namespace: end
3129
NULL
3230

R/testing.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,5 +379,5 @@ skip_during_parallel <- function() {
379379
Sys.getenv("STYLER_TEST_IS_TRULY_PARALLEL", TRUE) %>%
380380
toupper() %>%
381381
as.logical() %>%
382-
testthat::skip_if()
382+
testthat::skip_if("Running in parallel")
383383
}

R/transform-code.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ transform_code <- function(path, fun, ..., dry) {
2222
..., dry = dry
2323
)
2424
} else {
25-
abort(paste(path, "is not an R, Rmd or Rnw file"))
25+
abort(paste(path, "is not an R, Rmd, qmd, or Rnw file"))
2626
}
2727
}
2828

R/transform-files.R

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,16 @@ verify_roundtrip <- function(old_text, new_text, parsable_only = FALSE) {
418418
error = function(e) {
419419
rlang::abort(paste0(
420420
"Styling resulted in code that isn't parsable. This should not ",
421-
"happen. Please file a bug report on GitHub ",
422-
"(https://github.com/r-lib/styler/issues) using a reprex."
423-
))
421+
"happen."
422+
), .internal = TRUE)
424423
}
425424
)
426425
} else if (!expressions_are_identical(old_text, new_text)) {
427426
msg <- paste(
428427
"The expression evaluated before the styling is not the same as the",
429-
"expression after styling. This should not happen. Please file a",
430-
"bug report on GitHub (https://github.com/r-lib/styler/issues)",
431-
"using a reprex."
428+
"expression after styling. This should not happen."
432429
)
433-
abort(msg)
430+
abort(msg, .internal = TRUE)
434431
}
435432
}
436433

R/vertical.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ print.vertical <- function(x, ...,
2525
x <- prettycode::highlight(x, style = style)
2626
} else {
2727
warn(paste(
28-
"Could not use colored = TRUE, as the package prettycode is not",
28+
"Could not use `colored = TRUE`, as the package prettycode is not",
2929
"installed. Please install it if you want to see colored output",
3030
"or see `?print.vertical` for more information."
3131
))

0 commit comments

Comments
 (0)