Page MenuHomePhabricator

How to handle test functions with MediaWiki.Commenting.FunctionComment.MissingParamTag sniff
Closed, ResolvedPublic

Description

mediawiki/core currently exclude the tests folder for MediaWiki.Commenting.FunctionComment.MissingParamTag, because it reports some test functions who missing @param tags

At the moment the FunctionComment Sniff skips classes ends with *Test.php, but mediawiki/core contains some *TestBase classes containing test functions with @dataProvider and that means the function have arguments which want the sniff to be documented.

It would be nice to have the sniff in tests for the non-test functions working.

So how to make this better?
Remove the overall Test.php from FunctionCommentSniff and add a check for test* functions instead when reporting missing @param (or @return)?

PhpunitAnnotationsSniff already have some regex to check for test, so that needs refactoring for reuse that logic.

The other way is to document @param on tests, but that may not so helpful

Event Timeline

Change 655188 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/tools/codesniffer@master] Check @param/@return on files ending in Test.php

https://gerrit.wikimedia.org/r/655188

Umherirrender triaged this task as Low priority.

Change 655188 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Check @param/@return on files ending in Test.php

https://gerrit.wikimedia.org/r/655188

After release of new codesniffer the exclusion from .phpcs.xml in mediawiki/core could be removed and remaining issues fixed, because there are not than not related to test* functions

Change 660915 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Add missing @param tags in tests

https://gerrit.wikimedia.org/r/660915

Change 660915 merged by jenkins-bot:
[mediawiki/core@master] Add missing @param tags in tests

https://gerrit.wikimedia.org/r/660915