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

Support exclusion comments #542

Closed
michaelquinn32 opened this issue Sep 10, 2019 · 6 comments
Closed

Support exclusion comments #542

michaelquinn32 opened this issue Sep 10, 2019 · 6 comments

Comments

@michaelquinn32
Copy link
Contributor

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

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Sep 10, 2019

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.

@michaelquinn32
Copy link
Contributor Author

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.

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Oct 8, 2019

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.

@lorenzwalthert lorenzwalthert reopened this Oct 8, 2019
@lorenzwalthert
Copy link
Collaborator

No let's open the original issue.

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Oct 22, 2019

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

remotes::install_github("lorenzwalthert/styler@stylerignore")

@lorenzwalthert
Copy link
Collaborator

Closed with #560.

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

No branches or pull requests

2 participants