Skip to content

Commit 5ee66ba

Browse files
Merge branch 'main' into routine
2 parents 4800cea + 444a2fb commit 5ee66ba

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Imports:
2929
cyclocomp,
3030
digest,
3131
glue,
32-
jsonlite,
3332
knitr,
3433
rex,
3534
stats,
@@ -39,6 +38,7 @@ Imports:
3938
Suggests:
4039
bookdown,
4140
httr (>= 1.2.1),
41+
jsonlite,
4242
mockery,
4343
patrick,
4444
pkgdown,

R/comments.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ github_comment <- function(text, info = NULL, token = settings$comment_token) {
8686
if (!requireNamespace("httr", quietly = TRUE)) {
8787
stop("Package 'httr' is required to post comments with github_comment().")
8888
}
89+
if (!requireNamespace("jsonlite", quietly = TRUE)) {
90+
stop("Package 'jsonlite' is required to post comments with github_comment().")
91+
}
8992

9093
if (is.null(info)) {
9194
info <- ci_build_info()

R/lint.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ checkstyle_output <- function(lints, filename = "lintr_results.xml") {
569569
#' @param filename the name of the output report
570570
#' @export
571571
sarif_output <- function(lints, filename = "lintr_results.sarif") {
572+
if (!requireNamespace("jsonlite", quietly = TRUE)) {
573+
stop("'jsonlite' is required to produce SARIF reports, please install to continue.")
574+
}
572575

573576
# package path will be `NULL` unless it is a relative path
574577
package_path <- attr(lints, "path")
@@ -716,8 +719,7 @@ sarif_output <- function(lints, filename = "lintr_results.sarif") {
716719
append(sarif$runs[[1L]]$results, list(one_result))
717720
}
718721

719-
write(jsonlite::toJSON(sarif, pretty = TRUE, auto_unbox = TRUE),
720-
filename)
722+
write(jsonlite::toJSON(sarif, pretty = TRUE, auto_unbox = TRUE), filename)
721723
}
722724

723725
highlight_string <- function(message, column_number = NULL, ranges = NULL) {

tests/testthat/test-sarif_output.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
skip_if_not_installed("jsonlite")
2+
13
test_that("`sarif_output` produces expected error", {
24
l <- lint(text = "x = 1", linters = assignment_linter())
35
expect_error(sarif_output(l), "Package path needs to be a relative path", fixed = TRUE)

0 commit comments

Comments
 (0)