diff --git a/.lintr b/.lintr index 27c6bef4..36675671 100644 --- a/.lintr +++ b/.lintr @@ -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")) diff --git a/R/diagnostics.R b/R/diagnostics.R index 7c534333..5078a657 100644 --- a/R/diagnostics.R +++ b/R/diagnostics.R @@ -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