Skip to content

Commit

Permalink
Merge pull request #654 from REditorSupport/diagnose-path-check
Browse files Browse the repository at this point in the history
Check path in diagnose_file
  • Loading branch information
renkun-ken committed Jan 28, 2024
2 parents d6de18d + fc4b06d commit 5dcf744
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ linters: linters_with_defaults(
object_length_linter = NULL,
object_name_linter = NULL,
commented_code_linter = NULL,
cyclocomp_linter = NULL)
cyclocomp_linter = NULL,
indentation_linter(indent = 4, hanging_indent_style = "never"))
7 changes: 6 additions & 1 deletion R/diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ diagnose_file <- function(uri, content, is_rmarkdown = FALSE, globals = NULL, ca
on.exit(do.call("detach", list(env_name, character.only = TRUE)))
}

lints <- lintr::lint(path, cache = cache, text = content)
if (file.exists(path)) {
lints <- lintr::lint(path, cache = cache, text = content)
} else {
lints <- lintr::lint(text = content, cache = cache)
}

diagnostics <- lapply(lints, diagnostic_from_lint, content = content)
names(diagnostics) <- NULL
diagnostics
Expand Down

0 comments on commit 5dcf744

Please sign in to comment.