Closed
Description
In languageserver, we have to pass the file content to lintr::lint() (since the file is often being edited but not saved, and we do provide live diagnostics on user input) but also want it to behave as if the content is from a filename so that the following cases could work:
linter_fileis respected (.lintr defaults are not respected REditorSupport/languageserver#235)object_usage_linterdetects its package (Packages not loaded prior to linting with coc-r-lsp REditorSupport/languageserver#238)- Exclusions in
.lintrnot working (Exclusions in .lintr not working REditorSupport/languageserver#282)
One bad solution is to write a temp file inside the user workspace (e.g. original file test.R and we write a temp test.Rtmp) but Language Server Protocol seems to discourage any change in user workspace directly rather than via LSP communication.
Therefore, I'm wondering if we could add a text argument so that we could use
lintr::lint(filename, linters = NULL, cache = FALSE, ..., parse_settings = TRUE, text = NULL)by supplying both filename and text:
lintr::lint(filename, text = text)so that both are respected and lint wouldn't have to read the file again if text is supplied.
Reacted by Michel Lang, Luke Hannan, Nathan Eastwood, Alex Gable and Salim B
Activity
jimhester commentedon Jun 23, 2020
Sure, seems reasonable, you can open a PR with the necessary changes.
jimhester commentedon Jun 23, 2020
Also @renkun-ken if you are interested in contributing more to lintr I can invite you as a collaborator.
renkun-ken commentedon Jun 24, 2020
@jimhester I could make a PR for this, and of course I'm interested in contributing more to lintr as a collaborator. Thanks!