-
-
Notifications
You must be signed in to change notification settings - Fork 78
Generic/DocComment: improve code coverage #242
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
Generic/DocComment: improve code coverage #242
Conversation
@rodrigoprimo Good observation, but this is exactly as it should be. PHPCS needs to be able to flag these kind of user errors and should therefore tokenize it in a way that allows us to do so. |
For clarity I'm copying the commit message referred to above here:
@rodrigoprimo While I understand your reasoning, I don't think the reasoning is correct.
As for:
That raises some questions. I mean, I would expect the files to be different as JS is a different language than PHP, but the error list is the same, so how have they diverged ? |
What I meant to say when I said that they diverged is that there are two comments that were added to the PHP test case file but not to the JS test case file: That led me to believe that I should add the new tests only to the PHP file.
👍 I pushed new commits copying the missing tests from the main PHP test case file to the JS test case file and undoing the change that I made to |
Ah. That was an oversight from my side as those tests didn't (and shouldn't) yield any errors. I would have caught it when adding them if they did yield errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigoprimo Thanks for making those additional changes. All looks good now.
I will rebase the PR and squash some of the commits together now (without making changes) to get this ready for commit.
This commit copies two tests from the PHP test case file to the JS test case file. Now the files are synched and the same list of errors can continue to be used for both in DocCommentUnitTest.php.
Doing this to be able to move a test that needs to be on the last line to a separate file.
Moving a test that needs to be on the last line to its own file. I modified the comment message as, far as I could check, the sniff code to bail early if the doc comment is not properly closed works (as it should) even if there are new lines after it.
Adds two tests to check that the sniffer triggers an error when it finds empty doc comments.
c2e890e
to
91cc7bb
Compare
Ended up making some tiny tweaks:
|
Description
This PR improves the code coverage for the Generic.Commenting.DocComment sniff.
See commit messages for more details on the reasoning behind some of the changes, including one that I'm not sure if I took the best approach (handling errors in different lines for the JS and PHP test case files).
While working on this PR, I noticed that PHPCS considers
/**/
a doc comment, but php.net states that "doc comments start with /**, followed by whitespace" (https://www.php.net/manual/en/reflectionclass.getdoccomment.php). I'm not sure why PHPCS doesn't require the whitespace after/**
, but this seems to be intentional. Here is the commit that introduced this change: 8c64ded. I'm sharing this here in case it is something that we want to further investigate.Related issues/external references
Part of #146
Types of changes
PR checklist