-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Is there a documentation of just all sniffs and what they do, possibly including parameters? #1752
Comments
Example from another tool: https://eslint.org/docs/rules/ shows all "stock" rules as well as examples of allowed and not allowed for each. |
Some sniffs have docs in a Docs folder, which can be printed by using the You wont be able to create documentation from just parsing doc blocks because PHPCS sniffs are a collection of sniff codes, each checking something different. You need to actually go through the sniff and check the error messages, then document each code and what it does. It's a huge job. |
@gsherwood IMO the doc comments will suffice for a first draft at least? Squiz.Debug.JSLintRuns jslint.js on the file. declared in Squiz.Debug.JavaScriptLintRuns JavaScript Lint on the file. declared in PSR1.Classes.ClassDeclarationChecks the declaration of the class is correct. declared in PSR1.Files.SideEffectsEnsures a file declares new symbols and causes no other side effects, or declared in Still to do is to group and order it by standard, category and sniff name, but I think that'd be helpful already for browsing. In the future this can be augmented by additional information like accepted parameters etc, maybe again with help of annotations, e.g. by Doctrine's AnnotationReader. WDYT? |
Thanks for generating that list, but I wouldn't publish it in the PHPCS docs because I know the content isn't good enough, which means I'll get people asking for corrections and clarifications. If I'm going to publish docs, they need to be accurate and I know the comments are not clear enough as to what the sniffs actually do and aren't able to show just how many checks are actually performed. The sort of docs I want to produce have information about the checks + code examples where appropriate. You can see an example by running |
Closing this to roll the discussion into one idea. There was already #1603 for this, but I forgot about ti. |
Oh my... I'm pulling out my hair trying to find this exact list of rules. Clicked around the wiki a lot of times, googled a couple of rules, and only found samples or tutorials. After understanding the internal name for those rules is "sniff", I ended up here. I've already worked a bit with other linters, such as ESLint which got cited above... It's very easy to understand what you want to change in your ruleset and whatnot, but it's very surprising to see such an old tool like PHPCS not having anything like that. I'm pretty sure we all know that some documentation is better than no documentation at all. After all, now I understand why PHPCS is much less used than tools like ESLint. Because it's not really user-friendly :( |
I'm one person with a very full-time job + 2 kids + I don't make any money from PHPCS. I get some great contributions, but almost none have anything to do with documentation. Anything I do accept into the code needs to be kept up-to-date, and I know I barely have enough time to work on PHPCS bugs and feature as it is. This is why. I could really use help. And not one-off help. I need consistent help to maintain a project that has grown bigger and bigger over the years. |
Sad story of many open source projects, I completely understand your reasons.
I only still have a hard time getting why no documentation is better than "documented but noted as could be outdated". I mean, are new styling rules created every time? And if they included, couldn't you simply request a doc update as well?
It might just be my own taste, but it feels much more common to have to customize a rules file, and this is very out of place with other linters... And I've used others before coming to PHPCS 🤷🏼♂️
|
Any update to this? @gsherwood, did you get the help you needed? |
2 years later and just finding this thread...I do have to agree with the others on this coming into this library and finding a lot of use out of it but honestly the documentation is missing an entire section not having any of the rules and their descriptions. It has been hard for me to find built-in rules and so I have opted to just use the Slevomat coding standard since all of their rules are documented. The built-in rules that I am using are just ones that I found randomly and found out they worked how I wanted but there was no documentation (and there is no way I would be able to find out the parameters to use for configurable rules). I totally understand your concerns about maintenance but there is an easy solution to that - require all PRs to have changes to the documentation of the rules that they touch. This is done in many other repos because of the same concerns that you have. I have found a lot of value out of this linter but not having documentation on the rules could be a barrier on me using it long-term. I have a feeling that could also be a barrier for others and could prevent more meaningful contributions to the project. |
Just for anyone coming across this thread: a lot of sniffs have documentation on what the sniff looks for, including code samples. To view it, use: phpcs --standard=PSR12 --generator=text You can, of course, replace the standard name |
@jrfnl would it be terribly hard to have a loop that generates an .md file with the output of the command you mentioned? Seems like this could be a nice way to maintain everything - as long as each PR is enforcing the update of the generated text when necessary seems like it could be pretty straightforward. |
@mycarrysun I'm not sure what you mean ? You can pipe the output of the command I mention to an md file. Or do you mean to add to the docs here ? If so, that's not my decision. I did open a PR a while back to add a CI check for all sniffs being accompanied by tests and a doc file, but that got closed: #2872 |
To add to this thread, per @gsherwood's comment in #2489 (comment):
As I stated in #2489, I am happy to help with the documentation effort, but I'd rather not spend the time doing it in a format that the author considers potentially dead nor as some side project split off from PHPCS as that would just make maintaining it (and gaining traction) all the more difficult. |
Yes, this is what I meant - so that devs don't need to know how to loop through or even that the command argument is In the meantime, it might be nice to make a prominent note of the |
I hear you. All the same, I'd been playing with some ideas around this for a while, just haven't had the time to action it. For now, I've written up the rough idea I have: PHPCSStandards/PHPCSStandards.github.io#1 |
I know
phpcs -e
but I miss an explanation what each sniff does; respectively I miss a documentation in the wiki or something like this.If there isn't I might try to build something which extracts the explanation from the well-written doc block:
The text was updated successfully, but these errors were encountered: