Page MenuHomePhabricator

Enable PhanUndeclaredVariable rule in MediaWiki core
Closed, ResolvedPublic

Description

See for example https://gerrit.wikimedia.org/r/#/c/244051/1/includes/jobqueue/jobs/AssembleUploadChunksJob.php.

The PhpStorm (IntelliJ IDEA) inspector for PHP code has a PhpUnusedLocalVariableInspection rule. It'd be nice to have this rule in our code sniffer so that users can configure their editor to use PHPCS and get this warning as well (and enforce it via Jenkins).

See:

Event Timeline

Krinkle created this task.Oct 7 2015, 2:06 AM
Krinkle raised the priority of this task from to Needs Triage.
Krinkle updated the task description. (Show Details)
Krinkle added a project: MediaWiki-Codesniffer.
Krinkle added subscribers: Krinkle, aaron, Legoktm.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 7 2015, 2:06 AM
Krinkle updated the task description. (Show Details)Oct 7 2015, 2:06 AM
Krinkle set Security to None.

We already have a sniff that is able to detect unused global variables, something like it could be used to detect normal variables that are unused.

Krinkle triaged this task as Medium priority.Jul 27 2016, 12:48 AM

Make sure it handle ScopedCallback and similar things.

Legoktm updated the task description. (Show Details)Jul 23 2017, 10:32 PM
MaxSem added a subscriber: MaxSem.Mar 16 2018, 7:25 AM

In the light of Phan being available, it this still relevant?

I agree Phan seems more likely to handle this than CodeSniffer. And indeed it has a rule for it: PhanUndeclaredVariable. However, it seems we don't have this enabled right now.

Krinkle renamed this task from Add rule for unused variables to Enable PhanUndeclaredVariable rule in MediaWiki core.Mar 17 2018, 3:41 AM
Krinkle lowered the priority of this task from Medium to Low.
Krinkle edited projects, added MediaWiki-Core-Testing; removed MediaWiki-Codesniffer.
Krinkle raised the priority of this task from Low to Medium.Aug 24 2018, 8:48 PM
Krinkle claimed this task.Aug 24 2018, 11:09 PM

Change 455263 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] [WIP] Try to trigger PhanUndeclaredVariable

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

Change 455263 abandoned by Krinkle:
[WIP] Try to trigger PhanUndeclaredVariable

Reason:
Works.

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

Krinkle closed this task as Resolved.Aug 24 2018, 11:43 PM
Krinkle removed a project: Patch-For-Review.
Krinkle added a project: Performance-Team.