Skip to content
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

PhpdocToCommentFixer - Add ignored_tags option #5572

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

VincentLanglet
Copy link
Contributor

Sometimes, the docblock are necessary inside the code. This is the case for

/** @psalm-suppress */

This option allow to ignore some comments.

Closes: #5505

@coveralls
Copy link

coveralls commented Mar 22, 2021

Coverage Status

Coverage increased (+0.008%) to 92.189% when pulling db400cf on VincentLanglet:feature/ignoreTag into e5ebc7f on FriendsOfPHP:master.

@VincentLanglet VincentLanglet force-pushed the feature/ignoreTag branch 2 times, most recently from 75356c6 to cf4d6ca Compare March 22, 2021 22:40
@VincentLanglet VincentLanglet changed the title Add ignore_tags option Add ignored_tags option Mar 22, 2021
@VincentLanglet
Copy link
Contributor Author

Hi @keradus, this is my first PR on this project.
I'm sorry but I don't understand the test failure.

Copy link
Contributor

@kubawerlos kubawerlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VincentLanglet to fix failing tests you have to regenerate docs: php ./dev-tools/doc.php.

src/Fixer/Phpdoc/PhpdocToCommentFixer.php Outdated Show resolved Hide resolved
src/Fixer/Phpdoc/PhpdocToCommentFixer.php Outdated Show resolved Hide resolved
@VincentLanglet
Copy link
Contributor Author

@VincentLanglet to fix failing tests you have to regenerate docs: php ./dev-tools/doc.php.

But this command is changing the example 2.
It's like it's not using my second code sample.

@kubawerlos
Copy link
Contributor

But this command is changing the example 2.
It's like it's not using my second code sample.

I don't thin I get it - you already updated the docs with example 2 (as it's visible in diff), but it looks like you made some changes later. I believe if you regenerate docs the diff in this PR will look correctly.

@VincentLanglet
Copy link
Contributor Author

I don't thin I get it - you already updated the docs with example 2 (as it's visible in diff), but it looks like you made some changes later. I believe if you regenerate docs the diff in this PR will look correctly.

The doc update does

    --- Original
    +++ New
-   @@ -1,7 +1,7 @@
+   @@ -1,12 +1,12 @@
     <?php
     $first = true;// needed because by default first docblock is never fixed.
 
-   -/** This should be a comment */
-   +/* This should be a comment */
+   -/** This will be changed */
+   +/* This will be changed */
+    foreach($connections as $key => $sqlite) {
+        $sqlite->open($path);
+    }
+
+    /** @todo This will not be changed */
     foreach($connections as $key => $sqlite) {
         $sqlite->open($path);
     }

Basically it replaces my second example by the first one.

@kubawerlos
Copy link
Contributor

Basically it replaces my second example by the first one.

@VincentLanglet not really, these are the changes from - your - 2nd example, they are just produce exactly the same as 1st example. To see it more clearly change something in your example, like variable $connections to $array and regenerate the docs.

@VincentLanglet
Copy link
Contributor Author

Basically it replaces my second example by the first one.

@VincentLanglet not really, these are the changes from - your - 2nd example, they are just produce exactly the same as 1st example. To see it more clearly change something in your example, like variable $connections to $array and regenerate the docs.

Oh, I see.

Since

/** @todo This should be a PHPDoc as the tag is on "ignored_tags" list */
foreach($connections as $key => $sqlite) {
    $sqlite->open($path);
}

is untouched, it's not in the diff !

@kubawerlos
Copy link
Contributor

Exactly, I address this issue in #5585

Copy link
Contributor

@kubawerlos kubawerlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have 2 more test cases:

  • one with tag in different casing in code and config
  • with PHPDoc having 2 different tags and only one of them in config

tests/Fixer/Phpdoc/PhpdocToCommentFixerTest.php Outdated Show resolved Hide resolved
tests/Fixer/Phpdoc/PhpdocToCommentFixerTest.php Outdated Show resolved Hide resolved
tests/Fixer/Phpdoc/PhpdocToCommentFixerTest.php Outdated Show resolved Hide resolved
@VincentLanglet
Copy link
Contributor Author

Done @kubawerlos :)

@kubawerlos
Copy link
Contributor

@VincentLanglet for "PHPDoc having 2 different tags and only one of them in config" I meant PHPDoc like this:

/**
 * @foo text
 * @bar text
 */

and ignored tags only foo.

@VincentLanglet VincentLanglet force-pushed the feature/ignoreTag branch 2 times, most recently from 9d0dc8b to 1420e74 Compare April 3, 2021 21:29
@VincentLanglet
Copy link
Contributor Author

@kubawerlos Done, tahnks to this test, I discovered I should use matchAll. :)

Copy link
Contributor

@kubawerlos kubawerlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VincentLanglet I cannot fint that test with PHPDoc having multiple tags

src/Fixer/Phpdoc/PhpdocToCommentFixer.php Outdated Show resolved Hide resolved
@VincentLanglet
Copy link
Contributor Author

@VincentLanglet I cannot fint that test with PHPDoc having multiple tags

I have added an example but no tests.
But now there is also a test with multiple tags.

Copy link
Contributor

@kubawerlos kubawerlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last question for this PR is: should target aim master or 3.0 instead of 2.18?

@keradus how should new features be handled now? There is not milestone 2.19 - does it mean 2.18 is last minor in v2 series and new features should aim 3.0?

@keradus
Copy link
Member

keradus commented Apr 5, 2021

(each new) feature should be targetting master, imho
under which tag it would get released is another story, not blocking here

@VincentLanglet VincentLanglet changed the base branch from 2.18 to master April 5, 2021 11:50
@VincentLanglet
Copy link
Contributor Author

@keradus @kubawerlos Is there any interest in this PR or should I close it ?

@julienfalque
Copy link
Member

@VincentLanglet I think this feature is interesting and should be merged, but this requires time and maitainers don't have much these days, please be patient :)

@VincentLanglet
Copy link
Contributor Author

@VincentLanglet I think this feature is interesting and should be merged, but this requires time and maitainers don't have much these days, please be patient :)

Sure, I understand this. I was just expecting at least one comment to be sure I don't rebase (and fix the conflict) regularly for nothing.

The branch is now up to date. Let's wait and see 🤞🏻 =)

@kubawerlos
Copy link
Contributor

This is definitely something worth merging, but only @keradus, @SpacePossum and @julienfalque can do it, approving running workflow before that.

@VincentLanglet
Copy link
Contributor Author

Friendly ping @keradus

@VincentLanglet
Copy link
Contributor Author

@keradus Would it be possible to get some review ? :)

@julienfalque julienfalque added kind/feature RTM Ready To Merge labels Jul 30, 2021
@julienfalque julienfalque added this to the 3.1.0 milestone Jul 30, 2021
@SpacePossum SpacePossum changed the title Add ignored_tags option PhpdocToCommentFixer - Add ignored_tags option Jul 30, 2021
@SpacePossum
Copy link
Contributor

I think we could do with 2 examples, one with default config and one with a single excluded tag.
Maybe we should document that the excluded tags are matched case insensitive as well.

@keradus keradus removed the RTM Ready To Merge label Jul 30, 2021
@VincentLanglet
Copy link
Contributor Author

I think we could do with 2 examples, one with default config and one with a single excluded tag.
Maybe we should document that the excluded tags are matched case insensitive as well.

There is already 4 examples

  • One with default config
  • One with single excluded tag
  • One to show it's cade insensitive
  • One to show it support multiple tag in the same docblock

@SpacePossum
Copy link
Contributor

Yeah I saw the 4, but I think 2 is enough if we would update the docs stating the ignored tags are matched case insensitive.

Having more tests would be better than more examples. Like a test with @ignore-me for the special chars from the regex, @TODO to test the case insensitive matching works, @TODOnot to test the word matching works (so it doesn't match when configured 'todo'). What would be a sane tag look like to have the \\\\ in the regex?

@VincentLanglet
Copy link
Contributor Author

Done @SpacePossum

@SpacePossum
Copy link
Contributor

thanks 👍 if the pipeline succeeds than RTM from me

@VincentLanglet
Copy link
Contributor Author

thanks 👍 if the pipeline succeeds than RTM from me

Tests were failing because of the doc, it might be better now I hope.

@kubawerlos kubawerlos added the RTM Ready To Merge label Jul 30, 2021
@keradus keradus removed the RTM Ready To Merge label Aug 2, 2021
@keradus
Copy link
Member

keradus commented Aug 2, 2021

Thank you @VincentLanglet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

phpdoc_to_comment and @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter
6 participants