Description
Is your feature request related to a problem?
Searching for proper sniffs/sniffs explanations was always a complicated thing when using phpcs
, at least for me, especially as a newcomer. I've had several approaches over the years to this, without success, and now I've decided to give it a try one more.
What problems I have before digging deeper in the phpcs codebase?
-
Building own ruleset: When I wanted to build my own ruleset I couldn't find an easy way to find the sniff codes that I should include. Some sniffs include docs, that can be generated with
phpcs --standard=Generic --generator=text
but the codes are not available there so when I found something useful, I had to use a little bit of reverse engineering to find out the code. -
Getting sniffs explanations: I know that we can get a sniff explanation (when docs exist) with
phpcs --standard=Generic --generator=text --sniffs=Generic.Metrics.CyclomaticComplexity
but it would be also nice to search for them easier, especially for newcomers.
When I was searching for solutions I found a few discussions with similar concerns. That's why I decided to ask for this.
Describe the solution you'd like
It would be much easier for me as a beginner if the sniff code were available in the docs generated with --generate
attribute. So I could just generate the docs for specific standards, select the sniffs that I'm interested in, and take the sniff codes easily. Of course, it's not impossible to find out the code, but such a simple improvement would be nice.
I've already decided to give it a try for my internal needs and It was really useful! The changes/propositions:
- Display sniff code in the documentation created with
--generate
tag. - Allow to set the sniff code in the
code
attribute of thedocumentation
XML tag (optional). - When the sniff code is not set in the mentioned tag, it is automatically detected by phpcs engine and set.
Thanks to this I'm able to:
- Review the generated docs and find the sniff codes to include/exclude them in the ruleset much faster.
- Find more information about errors much easier by searching info by sniff code.
I'm aware that I might miss something crucial that would similarly solve those problems, but if not, maybe it will be useful for others. What do you think?
Screenshots
HTML

Text

Markdown

Additional context (optional)
- I intend to create a pull request to implement this feature.