Page MenuHomePhabricator

[REPO] [CLIENT] Reenable FunctionComment and Cleanup PropertyDocumentation phpcs sniffs in Wikibase
Closed, ResolvedPublic

Description

Since mediawiki-codesniffer v41 (T325201), the FunctionComment and Cleanup PropertyDocumentation sniffs are more lenient about allowing missing doc comments as long as information is provided by static types, which removes the main reason we disabled them in Wikibase (I believe). We should reenable the sniffs, to catch legitimate errors like the ones seen below, as well as to discover places where neither a doc comment nor a static type is present.

Acceptance Criteria:

  • MediaWiki.Commenting.FunctionComment.ParamNameNoMatch sniff is enabled in Wikibase
  • MediaWiki.Commenting.FunctionComment.ParamPassByReference sniff is enabled in Wikibase
  • All violations of these rules are fixed
  • Remove any comments that were added in change 1064919 and replace them with type hints

Notes:

  • In most cases we’ll want to resolve errors by adding static types, not doc comments.
  • Example of legitimate violations:
FILE: /var/www/html/wiki1/extensions/Wikibase/client/includes/Serializer/ClientEntitySerializer.php                                                                                                                                                                                                                                                        
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                  
FOUND 2 ERRORS AFFECTING 2 LINES                                                                                                                                                                                                                                                                                                                           
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                  
 36 | ERROR | Doc comment for parameter $filterLangCodes does not match actual variable name $entityIdParser (MediaWiki.Commenting.FunctionComment.ParamNameNoMatch)                                                                                                                                                                                       
 37 | ERROR | Doc comment for parameter $termFallbackChains does not match actual variable name $filterLangCodes                                                                                                                                                                                                                                           
    |       | (MediaWiki.Commenting.FunctionComment.ParamNameNoMatch)                                                                                                                                                                                                                                                                                      
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                  

FILE: /var/www/html/wiki1/extensions/Wikibase/client/includes/Store/DescriptionLookup.php                                                                                                                                                                                                                                                                  
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                            
FOUND 2 ERRORS AFFECTING 2 LINES                                                                                                                                                                                                                                                                                                                           
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                            
  67 | ERROR | [x] Pass-by-reference for parameter $actualSources does not match pass-by-reference of variable name $actualSources                                           
     |       |     (MediaWiki.Commenting.FunctionComment.ParamPassByReference)                                                                                                                                                                                                                                                                             
 105 | ERROR | [x] Pass-by-reference for parameter $actualSource does not match pass-by-reference of variable name $actualSource                                                                                                                                                                                                                           
     |       |     (MediaWiki.Commenting.FunctionComment.ParamPassByReference)                                                                                                                                                                                                                                                                             
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                            
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY                                                                                                                                                                                                                                                                                                 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Event Timeline

Change 892384 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] WIP: Reenable documentation sniffs

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

See this CI build for a list of errors / violations (as of PS1 of the above change).

Add $snakNamespace to ValueSnakRdfBuilder::addValue PHPDoc is an example of the kind of mistake / fix that this sniff would prevent, I think.

Lucas_Werkmeister_WMDE renamed this task from Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase to [REPO][CLIENT][SW] Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase.Apr 16 2024, 12:03 PM
karapayneWMDE subscribed.

removed from dev board until its can go through our prioritization pipeline

Prio Notes:

Impact AreaAffected
production / end usersno
monitoringno
development effortsyes
onboarding effortsno
additional stakeholdersno
ItamarWMDE renamed this task from [REPO][CLIENT][SW] Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase to [SW][REPO][CLIENT] Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase.Dec 6 2024, 11:59 AM
ItamarWMDE renamed this task from [SW][REPO][CLIENT] Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase to [SW] [REPO] [CLIENT] Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase.
ItamarWMDE renamed this task from [SW] [REPO] [CLIENT] Reenable FunctionComment and PropertyDocumentation phpcs sniffs in Wikibase to [REPO] [CLIENT] Reenable FunctionComment and Cleanup PropertyDocumentation phpcs sniffs in Wikibase.Dec 12 2024, 11:58 AM
ItamarWMDE updated the task description. (Show Details)

Change #1112357 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/Wikibase@master] Add function documentation to private functions

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

Change #1123327 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Replace phpdoc types with type annotations for private members

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

Change #1112357 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add function documentation to private functions

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

Change #1123360 had a related patch set uploaded (by Arthur taylor; author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] WIP: Reenable documentation sniffs

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

Change #892384 abandoned by Arthur taylor:

[mediawiki/extensions/Wikibase@master] WIP: Reenable documentation sniffs

Reason:

Replaced with Ie54947ebd3650976c0c5569408e690ad9b039e38 - sorry for the confusion!

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

Change #1123462 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/Wikibase@master] Add function documentation to function params

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

Change #1123462 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add function documentation to function params

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

Change #1123327 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace phpdoc types with type annotations for private members

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

Change #1123360 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Reenable documentation sniffs

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

MediaWiki.Commenting.FunctionComment.ParamPassByReference sniff is enabled in Wikibase

I’m not really sure what this is doing in the acceptance criteria tbh, given that AFAICT we never disabled it specifically in Wikibase… I guess it comes from the time before this change, because we originally disabled the whole FunctionComment sniff instead of only parts of it? But anyway, I think it’s enabled now (comes with mediawiki-codesniffer and we don’t disable it).