Skip to content

Support exclusion comments #542

Closed
Closed

Description

@michaelquinn32

This was mentioned in separate issues, but would be useful to track separately.

There are many cases where it might be useful to disable styler for either a line or across multiple lines. This is supported in jimhester/lintr with

  • "# nolint" excludes the line
  • "# nolint start" begins a block
  • "# nolint end" ends a block

This is similar to functionality in google/yapf:
https://github.com/google/yapf#why-does-yapf-destroy-my-awesome-formatting

Activity

  1. lorenzwalthert commented on Sep 10, 2019

    @lorenzwalthert
    Collaborator

    This is a duplicate of #365 and #533. As noted in these issues, we are working on detecting alignment to fix the most common case where styler falls short of the expectations. It's already done for function calls in the devel version of styler, the heuristic are outlined in the corresponding vignette.

  2. michaelquinn32 commented on Oct 8, 2019

    @michaelquinn32
    ContributorAuthor

    This should be reopened.

    We are coming close to a point where calling styler can happen by default as a precommit across all of our packages. But, we are facing some problems with some jobs that parse R files, as they weren't written with styler's formatting conventions in mind.

    Being able to turn styler off for these edge cases, and even better for just part of the code, would be really helpful.

  3. lorenzwalthert commented on Oct 8, 2019

    @lorenzwalthert
    Collaborator

    As pointed out, I don’t see a lot of value in that. I‘d prefer to focus on concrete cases and try to improve formatting there. If you have any, please open a new issue. The formatter should be so good that there is no need for exceptions. Also, implementing this feature is non-trivial and likely to slow down styler and make it more complex - for limited gain. Instead of marking many lines with nostyler, why not making them compliant?

    I might think about how to implement this a bit - if you have concrete suggestions, please let me know.

  4. lorenzwalthert commented on Oct 8, 2019

    @lorenzwalthert
    Collaborator

    No let's open the original issue.

  5. lorenzwalthert commented on Oct 22, 2019

    @lorenzwalthert
    Collaborator

    We have a draft :-). Feedback welcome, please in the PR (#560), not here in the issue.

    remotes::install_github("lorenzwalthert/styler@stylerignore")
  6. lorenzwalthert commented on Nov 30, 2019

    @lorenzwalthert
    Collaborator

    Closed with #560.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions