Skip to content

Add text argument to lintr::lint #475

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

Closed
renkun-ken opened this issue Mar 31, 2020 · 3 comments · Fixed by #503
Closed

Add text argument to lintr::lint #475

renkun-ken opened this issue Mar 31, 2020 · 3 comments · Fixed by #503
Labels
feature a feature request or enhancement
Milestone

Comments

@renkun-ken
Copy link
Collaborator

renkun-ken commented Mar 31, 2020

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:

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.

@jimhester
Copy link
Member

Sure, seems reasonable, you can open a PR with the necessary changes.

@jimhester
Copy link
Member

Also @renkun-ken if you are interested in contributing more to lintr I can invite you as a collaborator.

@renkun-ken
Copy link
Collaborator Author

@jimhester I could make a PR for this, and of course I'm interested in contributing more to lintr as a collaborator. Thanks!

@MichaelChirico MichaelChirico added this to the 3.0.0 milestone Jan 31, 2021
@AshesITR AshesITR added the feature a feature request or enhancement label Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants