Skip to content

Support clickable hyperlinks in lintr output if hyperlinks are available (but not markers) #2645

@olivroy

Description

@olivroy

i.e. in Positron, output looks like this
image

It would be great if hyperlinks are available, but not source markers (i.e. cli::ansi_has_hyperlink_support() && (!requireNamespace("rstudioapi") || !rstudioapi::hasFun("sourceMarkers") ) then we could just use

paths <- c("tests/spelling:1:1", "tests/spelling:1:2")
paths2 <- paste0("{.path ", paths, "}")
paths3 <- unlist(lapply(paths2, cli::format_inline))
cat(paths3, sep = "\n")

I am however not sure where to put this condition, I tried in

lintr/R/methods.R

Lines 95 to 99 in 8d96145

} else if (in_github_actions() && !in_pkgdown()) {
github_actions_log_lints(x, project_dir = github_annotation_project_dir)
} else {
lapply(x, print, ...)
}

} else if (in_github_actions() && !in_pkgdown()) { 
   github_actions_log_lints(x, project_dir = github_annotation_project_dir) 
 } else if (cli::has_hyperlink_support()) { 
  # Do some modification here?
 } else { 
   lapply(x, print, ...) 
 } 

But it didn't seem to work

This should happen in the print method to make sure no output is problematic.

I think it can happen in format.lint(). I may come up with a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions