-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Feature Request: ignore/exclude parts of a file in the coding standard xml file #3874
Comments
First off, the The PHPCS native supported annotations allow for selective ignoring, on a modular level - i.e. As for the feature request: how do you envision this ? I mean, would this be based on line nrs ? If so, that is highly unstable as just updating a docblock could already cause an "off-by-one" (or more) issue. |
This sounds similar to the 'baseline' feature in PHPStan. Perhaps a similar format could be used here: store the path, count, and code as a tuple. I've not yet looked into this in any real detail; my initial thoughts are that this could perhaps be a implemented as a custom report. |
There are a number of feature requests which are loosely related to the baseline feature in PHPStan. I've started tagging those with the Focus: Ignore Annotations/Excludes label to make them easier to find, though there are probably more which I haven't tagged yet. |
Ooff. Sorry about that. I meant to write I think the idea of @fredden could work - as we know that it works in phpstan. To be honest I was thinking about it more naively: And was just thinking about line numbers and ranges at first. These would be easy enough to adjust, remove or add - at least in my use case, since I would mainly need this in the end of my work, when committing to a codebase that doesn't have an official standard (only an implicit one) and no agreed upon tools to enforce it. Furthermore I use the CodeSniffer exlusively through vs code. Which means that I deal with one file at a time, so its not too overwhelming even in the case where line numbers would be the only way to mark ignored parts of files. With that said: A baseline would of course be smarter for use within pipelines and such. |
Discussed in #3873
Originally posted by finn-matti August 11, 2023
Context: We do not have a linter in use in our project, but none the less an informal standard is enforced. To make my life easier in MRs and make sure the code fits that informal standard, I use phpcs to point out and fix things. As we all know: You can't always fix all problems and have to use phpcs:ignore or similar. The problem is, of course, that comments like this shouldn't be part of the code base, since no one else is using phpcs (yet, I hope. But that's a different discussion). So I would like a way to ignore certain parts of files from the coding standard file (the xml file). I tried to search in issues and discussions and checked the wiki for this feature (to no avail)- but I thought I'd ask here, just to be sure.
It seems to me that this could be an interesting feature since I'm surely not the only one suffering from this. Another use case: Avoiding long phpcs:ignore comments like this one:
You can imagine if you need to suppress more rules lines can become very long. Why not allow partial exclusions of files in the xml file, too?
The text was updated successfully, but these errors were encountered: