Skip to content

Use {httr2}, not {httr} #2148

@MichaelChirico

Description

@MichaelChirico

{httr} is superseded in favor of {httr2}. We don't have much usage, so it should be "easy" to refactor in favor of the newer/better-supported package:

lintr/R/comments.R

Lines 85 to 115 in 203be65

github_comment <- function(text, info = NULL, token = settings$comment_token) {
if (!requireNamespace("httr", quietly = TRUE)) {
stop("Package 'httr' is required to post comments with github_comment().")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
stop("Package 'jsonlite' is required to post comments with github_comment().")
}
if (is.null(info)) {
info <- ci_build_info()
}
if (!is.null(info$pull) && info$pull != "false") {
api_subdir <- file.path("issues", info$pull)
} else if (!is.null(info$commit)) {
api_subdir <- file.path("commits", info$commit)
} else {
stop("Expected a pull or a commit, but received ci_build_info() = ", format(info))
}
response <- httr::POST(
"https://api.github.com",
path = file.path("repos", info$user, info$repo, api_subdir, "comments"),
body = list(body = jsonlite::unbox(text)),
query = list(access_token = token),
encode = "json"
)
if (httr::status_code(response) >= 300L) {
message(httr::http_condition(response, "error", task = httr::content(response, as = "text")))
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalsIssues related to inner workings of lintr, i.e., not user-visible

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions