Skip to content

Add text argument to lintr::lint #475

Closed

Description

@renkun-ken

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.

Activity

  1. jimhester commented on Jun 23, 2020

    @jimhester
    Member

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

  2. jimhester commented on Jun 23, 2020

    @jimhester
    Member

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

  3. renkun-ken commented on Jun 24, 2020

    @renkun-ken
    CollaboratorAuthor

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

  4. added this to the 3.0.0 milestone on Jan 31, 2021
  5. added
    feature
    on Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions