Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages not loaded prior to linting with coc-r-lsp #238

Closed
mllg opened this issue Mar 31, 2020 · 1 comment · Fixed by #284
Closed

Packages not loaded prior to linting with coc-r-lsp #238

mllg opened this issue Mar 31, 2020 · 1 comment · Fixed by #284

Comments

@mllg
Copy link

mllg commented Mar 31, 2020

Not sure if this is an issue of this package, or a problem of coc-r-lsp, but I'm encountering some difficulties setting them up to work together.

Although linting basically works out of the box, it looks like the current buffer is getting processed by lintr without loading the package (or any dependencies, imports, ...) first. This results in many warnings generated by the object_usage_linter. If I run languageserver::diagnose_file("<file>", readLines("<file>") everything looks good OTOH.

@renkun-ken
Copy link
Member

renkun-ken commented Mar 31, 2020

This is quite similar with the cause of #235 since languageserver::diagnose_file actually pass the content being edited (often not saved to disk) to lintr::lint() so its original path is lost so that linters that rely on it no longer works as expected.

object_usage_lintr is such a linter that relies on the file path to detect if it lives in a package (See https://github.com/jimhester/lintr/blob/master/R/object_usage_linter.R#L18) to determine its globals.

#236 resolves #235 but the root cause is still there. We'll probably have to find another way to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants