As a follow-up for #2222435: Add a sniff to ensure @todo comments follow the coding standards, we want to all check trailing line indentation.
We could also open a follow-up to check the indentation of lines that follow an @todo comment.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | todo2.txt | 1.69 KB | jonathan1055 |
Comments
Comment #2
jonathan1055 commentedWould this be a separate sniff? or just a new error/warning within the existing sniff file?
Comment #3
adamzimmermann commentedThat's a great question. I'm not sure.
I also wonder if the existing sniffs that check the indentation of others tags such as
@paramwill just automagically work for@todoas well. I seem to remember thinking about this during my work on the initial sniff. I don't remember where I landed with the idea or if I tested it though.So whoever starts on this first should check that idea and determine if any action is needed here at all. This might already be handled.
Comment #4
kingdutchThis is not currently flagged as incorrect in a function docblock in a class.
The following correctly formatted multiline todo is also not flagged, which is a good thing :)
Comment #5
adamzimmermann commented@Kingdutch thanks for testing this.
@jonathan1055 it seems that this should already be flagged, right? If this was
@paraminstead of@todothis would still be incorrect. I'm guessing that the@paramsniff is pretty targeted though. I'm wondering if we could make it more generic and repurpose it's logic. I wanted to get thoughts from you or anyone who has a better big picture understanding of what sniffs do what before any code was started though.Comment #6
jonathan1055 commentedI thought I would look to see what happens with indenting for @param and @var in docblock, and also regular comments and @todo in code. Attached is a test file, shown below with the output.
The current phpcs results are:
So it seems that the indentation errors in a function doc block are reported by a sniff of the type of tag e.g
@paramis covered byDrupal.Commenting.FunctionComment.ParamCommentIndentationbut @var does not have the equivalent. I did not look at @throws or @ingroup.In regular code comments, having too much indentation is already covered for @todo as well as plain comments. But having not enough indentation is not reported. Also some are fixable and others are not, but I guess that's a subsequent question to look at.
Comment #7
jonathan1055 commentedThere is a coding standards issue for discussing potential changes to the rules
#3444003: The text of an @todo should start with a capitalized word and sniff non-php files