-
Notifications
You must be signed in to change notification settings - Fork 16
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
Commenting.PackageSniff fix seems broken when first doc comment is an inline one #172
Comments
This is with the latest dev-main 85e9e0a. |
Hi @micaherne , thanks for reporting the problem, it looks really ugly! I'll give a try to it now, looking forward an acceptable solution, thanks! |
Ok, tracing down the problem it seems that the troubles are caused by In the mean time, and as a workaround, I think that if you add the file or class phpdoc block (the later is preferred in modern code), then you won't face the problem (it only happens when both phpdoc blocks are missing). If any of the blocks exist... then the fixer works ok, so far. I'm creating a test and, hopefully, a fix... ciao :-) |
Previously, we were allowing the getDocTagFromOpenTag() method to advance too much when looking for file phpdoc blocks. Now we stop as soon as any of the stop tokens is found. Note that this case is very edge one, only reproducible when there are lots of missing class/function phpdoc block, causing some other phpdoc block to be picked. In any case, I think that it's perfectly ok to shortcut the search that way, it can save us some precious iterations. Fixes moodlehq#172
Previously, we were allowing the getDocTagFromOpenTag() method to advance too much when looking for file phpdoc blocks. Now we stop as soon as any of the stop tokens is found. Note that this case is very edge one, only reproducible when there are lots of missing class/function phpdoc block, causing some other phpdoc block to be picked. In any case, I think that it's perfectly ok to shortcut the search that way, it can save us some precious iterations. Fixes moodlehq#172
I've created #173 that, hopefully, fixes this edge case (it's really edge!). In any case, if accepted, it will also save a few iterations when looking for those file phpdoc blocks. 🤞 Ciao :-) |
@micaherne , if you've any other case, different (structurally), from the above, it would be great to know about it. With the proposed patch, I think we are covered for any other combination. Ciao :-) |
Brilliant, thanks @stronk7! I haven't spotted any other issues with it so hopefully that'll be it. |
Previously, we were allowing the getDocTagFromOpenTag() method to advance too much when looking for file phpdoc blocks. Now we stop as soon as any of the stop tokens is found. Note that this case is very edge one, only reproducible when there are lots of missing class/function phpdoc block, causing some other phpdoc block to be picked. In any case, I think that it's perfectly ok to shortcut the search that way, it can save us some precious iterations. Fixes moodlehq#172
Previously, we were allowing the getDocTagFromOpenTag() method to advance too much when looking for file phpdoc blocks. Now we stop as soon as any of the stop tokens is found. Note that this case is very edge one, only reproducible when there are lots of missing class/function phpdoc block, causing some other phpdoc block to be picked. In any case, I think that it's perfectly ok to shortcut the search that way, it can save us some precious iterations. Fixes moodlehq#172
I'm seeing multiple issues with PackageSniff with code similar to this:
PHPCS is correctly identifying that there is no package tag:
But running the fix gives these two issues:
It tries to add the tag to the inline docblock where it's clearly not appropriate.
In the first pass it adds the tag to the end of the inline comment on the same line:
This is then detected as still violating the sniff, so it runs a second pass and adds it again on the line with the closing tag.
So the final diff is this:
The text was updated successfully, but these errors were encountered: