Page MenuHomePhabricator

Sniff UnusedUseStatement does not find all unused use statements
Closed, ResolvedPublic

Description

When reviewing https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/481998/ I asked me, why the codesniffer does not found this issue.

I have debugged codesniffer and the lbFactory in $this->lbFactory was detected as T_STRING. The compare against the class name is case-insensitive and thus the sniff thinks this was used.

The fix is to ignore property assignment in the sniff

Event Timeline

Change 482007 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/tools/codesniffer@master] Fix UnusedUseStatementSniff to ignore class property assignment

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

thiemowmde added a project: patch-welcome.
thiemowmde updated the task description. (Show Details)
thiemowmde subscribed.

Change 482007 merged by jenkins-bot:
[mediawiki/tools/codesniffer@master] Fix UnusedUseStatementSniff to find more unused statements

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

xSavitar added a subscriber: Legoktm.

Thanks @Umherirrender for working on this and @Legoktm for final review and landing the patch :)