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

Remove uneeded docblocks #25859

Closed
wants to merge 1 commit into from
Closed

Remove uneeded docblocks #25859

wants to merge 1 commit into from

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Jan 20, 2018

Q A
Branch? 2.7
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

Big cleanup (replaces #24931).

Thanks @TomasVotruba for doing all the hard work :)

Before merging, blanck lines between @param blocks and @throws/@return/ ... should be kept.

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Jan 20, 2018

@fabpot I just pushed fix for intertag blank lines in Symplify v3.2.4

Let me know if any more use cases fail

*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba Not sure why it removed the blackshash here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, this is also default behavior of ReflectionDocBlock. I'll look on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba Running the new version give me this error:

  Fixing of "src/Symfony/Component/HttpFoundation/Request.php" file by "Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDocBlockFixer" failed: Unknown modifier 'c' in pattern: #@see[\s]+(?<has_
  slash>\\)?https\://tools\.ietf\.org/html/rfc7231#section\-4\.2\.1# in file /Users/fabien/Code/github/Symplify/EasyCodingStandard/vendor/nette/utils/src/Utils/Strings.php on line 604

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in v3.2.6 and run on symfony/symfony 2.7 myself with success

Here is preview PR: 2.7...TomasVotruba:phpdocs-removal

with this ECS setup:

# ecs.neon

checkers:
    - PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer
    - Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDocBlockFixer

    # remove extra blank lines caused by previous fixer
    - Symplify\CodingStandard\Fixer\Commenting\RemoveEmptyDocBlockFixer
    - Symplify\CodingStandard\Fixer\Commenting\RemoveSuperfluousDocBlockWhitespaceFixer

Copy link
Contributor

Choose a reason for hiding this comment

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

I see there are few edge case. I'll try to fix some, but some are very difficult to catch with provided ReflectionDocBlock api. I'd have to write my own package to be able to resolve it correctly :)

@ostrolucky
Copy link
Contributor

it also broke phdoc alignments

@TomasVotruba
Copy link
Contributor

@ostrolucky That's responsibility of another fixer.

@ostrolucky
Copy link
Contributor

Right. But there might be issue with set priorities. Anyway I'm not blaming your fixer, but pointing to an issue in this PR.

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Jan 20, 2018

I see. I think @fabpot didn't run it with the other fixer.

@fabpot I recommend running this first, than "@symfony" set from PHP CS Fixer, that's how I use it in practise just in one ECS run. That would prevent any other fails that are covered by fixers.


@ostrolucky The PhpdocIndentFixer fixer is run first. I'll fix the priorities to make RemoveUselessDocBlockFixer run before it. Thanks 👍

@@ -210,7 +209,6 @@ private function dumpItem($dumper, $cursor, &$refs, $item)
*
* @param DumperInterface $dumper
* @param Cursor $parentCursor The cursor of the parent hash
* @param array &$refs A map of all references discovered while dumping
Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba Checking the diff, I think the current strategy is too aggressive. Here is one such example where the comment seems interesting and should probably be kept. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

@fabpot Thanks for comment. I've noticed this already. I think it's caused by & which probably leads parsing error and to empty comment.

I'm adding it to the cases to be fixed.

@fabpot
Copy link
Member Author

fabpot commented Jan 21, 2018

This PR is now ready to be reviewed. I've added a comment on one example where the comment should probably be kept instead of removed (as the description adds some value).

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Jan 21, 2018

There is 1 last issue reported in fabpot.io: https://fabbot.io/report/symfony/symfony/25859/3f375af281292adbdffb83ae5a6860bc45b393ea

What fixer takes care of that? I'll add it to my comment to complete the setup

@@ -144,8 +143,7 @@ protected function renderTable(Table $table, $decorated = false)
* Common options are:
* * name: name of described service
*
* @param Definition|Alias|object $service
* @param array $options
* @param Definition|\Alias|object $service
Copy link
Member

Choose a reason for hiding this comment

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

prepending \ to Alias is wrong

Copy link
Contributor

Choose a reason for hiding this comment

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

* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
* @param int $verbosity The threshold for verbosity
* @param string|array|\Process $cmd An instance of Process or an array of arguments to escape and run or a command to run
Copy link
Member

Choose a reason for hiding this comment

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

wrong \ on Process, class is correctly imported

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -80,8 +79,7 @@ public function run(OutputInterface $output, $cmd, $error = null, $callback = nu
* This is identical to run() except that an exception is thrown if the process
* exits with a non-zero exit code.
*
* @param OutputInterface $output An OutputInterface instance
* @param string|Process $cmd An instance of Process or a command to run
* @param string|\Process $cmd An instance of Process or a command to run
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed

* @param int|string|FormInterface $child
* @param null $type
* @param array $options
* @param int|string|\FormInterface $child
Copy link
Member

Choose a reason for hiding this comment

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

wrong \, I stop here :) the fixer seems to consider that classes are all coming from the global namespace

Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba Can you have a look at this issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed allong with &$value references.

I discovered one more error to resolve

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Jan 23, 2018

Last version to check: master...TomasVotruba:phpdos-removal-master

If you comment there, I'll try to fix that asap. Don't mind the indent, just docs removal.

Used set:

# easy-coding-standard
checkers:
    - Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDocBlockFixer
    - PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer
    - PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer

    # works best with these checkers, to remove empty docblock
    - Symplify\CodingStandard\Fixer\Commenting\RemoveSuperfluousDocBlockWhitespaceFixer
    - Symplify\CodingStandard\Fixer\Commenting\RemoveEmptyDocBlockFixer

@chalasr
Copy link
Member

chalasr commented Jan 23, 2018

@TomasVotruba Some annotations are replaced by an extra blank line, sometimes an extra blank line is just added between the phpdoc description and the first @param annotation:
b2d0a5b#diff-a10c9afd8feaccd1ff66ffd54e2835bcR925

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Jan 23, 2018

@chalasr Oh, I only used the remover fixer. But I've added space cleaner as well and updated the code. Ready for review 👍

@fabpot
Copy link
Member Author

fabpot commented Jan 23, 2018

I've just updated this PR with the new code (thanks @TomasVotruba)

* * Each tag is converted to a key value or an array
* if there is more than one "value"
* * Each tag is converted to a key value or an array
* if there is more than one "value"
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about this change. The space is needed to render proper Markdown.

* Use \Symfony\Component\DependencyInjection\ContainerBuilder::addExpressionLanguageProvider instead.
*
* @param ExpressionFunctionProviderInterface $provider
* Use \Symfony\Component\DependencyInjection\ContainerBuilder::addExpressionLanguageProvider instead.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the previous version is more readable and as it renders the same, I would not change this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is something I can't cover easily. I recommend reverting those manually.

* @param \Traversable $iterator
* $a and $b such that $a goes before $b in $expected, the method
* asserts that any element of $a goes before any element of $b
* in the sequence generated by $iterator
Copy link
Member Author

Choose a reason for hiding this comment

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

And here, I'm pretty sure that the indentation is wrong as this describes the $expected param.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is something I can't cover easily. I recommend reverting those manually.

@@ -1479,8 +1477,6 @@ public function isMethod($method)
*
* @see https://tools.ietf.org/html/rfc7231#section-4.2.1
*
* @param bool $andCacheable Adds the additional condition that the method should be cacheable. True by default.
Copy link
Member Author

Choose a reason for hiding this comment

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

This one should not be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll look on this one

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see it's commented bellow. This Fixer is not able to differentiate between commented argument and extra useless docs for param.

Just revert this manually

@@ -47,8 +47,6 @@ public function all()

/**
* Adds a route or collection.
*
* @param DumperRoute|DumperCollection The route or collection
Copy link
Member Author

Choose a reason for hiding this comment

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

Cannot be removed, I think it was removed as it's not valid. $child is missing here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is better to fix manually, since this Fixer relies on valid code.

@fabpot
Copy link
Member Author

fabpot commented Feb 7, 2018

@TomasVotruba Have you had time to have a look at the issues I've noticed here?

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Feb 8, 2018

@fabpot I missed your comments here, sorry. I'm looking into it.
Those are edge cases, that Fixer is unable to handle propperly without failing somewhere else.
Just revert manually.

@nicolas-grekas
Copy link
Member

@TomasVotruba would you like to take over doing the manual tweaks? Otherwise I'd suggest to close.

@TomasVotruba
Copy link
Contributor

@nicolas-grekas Sure. I can get to in till Friday.

@fabpot fabpot closed this Mar 29, 2018
@TomasVotruba
Copy link
Contributor

@nicolas-grekas I'll try to re-send this. Which branch should I target now?

@nicolas-grekas
Copy link
Member

3.4 is the oldest maintained branch now.

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Dec 2, 2018

@nicolas-grekas Ok

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.

None yet

7 participants