Page MenuHomePhabricator

(Re)move unused code reported by Vulture
Closed, ResolvedPublic

Description

There are some code pieces that are not used by Pywikibot and a quick scan with vulture creates the output below;

$ python -m vulture ./ --min-confidence 61
pywikibot/__init__.py:25: unused import 'handleArgs' (90% confidence)
pywikibot/__init__.py:25: unused import 'inputChoice' (90% confidence)
pywikibot/__init__.py:37: unused import 'NoSuchSite' (90% confidence)
pywikibot/__init__.py:946: unused variable 'repo_site' (100% confidence)
pywikibot/bot.py:101: unused import 'ShowingMultipleChoiceList' (90% confidence)
pywikibot/cosmetic_changes.py:994: unreachable code after 'return' (100% confidence)
pywikibot/tools/__init__.py:388: unreachable code after 'return' (100% confidence)
pywikibot/tools/__init__.py:461: unused variable 'exc_tb' (100% confidence)
pywikibot/tools/__init__.py:461: unused variable 'exc_type' (100% confidence)
pywikibot/tools/__init__.py:461: unused variable 'exc_val' (100% confidence)
pywikibot/tools/__init__.py:2094: unused variable 'exc_type' (100% confidence)
pywikibot/tools/__init__.py:2094: unused variable 'exc_value' (100% confidence)
scripts/makecat.py:90: unused variable 'catlist' (100% confidence)
scripts/redirect.py:632: unreachable code after 'break' (100% confidence)
tests/deprecation_tests.py:207: unused variable 'foo3' (100% confidence)
tests/deprecation_tests.py:207: unused variable 'foo4' (100% confidence)

(full report including 60% confidence where intentional unused methods helping bot writers and false positives can be found: P8046)

Setup Pywikibot locally and remove these unused codes. It will be also useful to recheck this report with vulture and also before making a patch, run unit tests to make sure no regressions have been introduced.

Acceptance Criteria

  • Submit a patch fixing 4 cases of unused code related to this task!

Event Timeline

Xqt triaged this task as Lowest priority.Sep 5 2018, 8:52 AM
Xqt added a project: good first task.

@Xqt I already contributed to pwb, should I leave this to newcomers for their first commit? (reacting to goodfirstbug tag)

@Xqt I already contributed to pwb, should I leave this to newcomers for their first commit? (reacting to goodfirstbug tag)

Could be an idea maybe for Google-Code-in-2018 but you could mentor that ;)

Wesalius added a subscriber: Wesalius.

I would need a mentor myself :-) Ok, leaving it then...

Dvorapa renamed this task from Remove unused code reported by Vulture to (Re)move unused code reported by Vulture.Sep 26 2018, 12:27 PM

Some of these could be relicts from not good patches etc.

Similar and really old one (taken from compat): T155337

Change 469433 had a related patch set uploaded (by Nathan fraignt; owner: Nathan fraignt):
[pywikibot/core@master] Removed unused vars/parameters from daemonize.py and data/api.py

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

Change 469433 merged by jenkins-bot:
[pywikibot/core@master] Removed unused vars/parameters from daemonize.py and data/api.py

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

Change 470848 had a related patch set uploaded (by Pipix; owner: Pipix):
[pywikibot/core@master] Remove Unused Code

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

I will help with mentoring too

Change 470848 merged by jenkins-bot:
[pywikibot/core@master] [cleanup] Remove unused code reported by Vulture

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

Dvorapa updated the task description. (Show Details)

Change 474727 had a related patch set uploaded (by Nils ANDRE; owner: Nils ANDRE):
[pywikibot/core@master] [cleanup] Remove unused code in 4 files

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

Change 475109 had a related patch set uploaded (by Arcayn; owner: Arcayn):
[pywikibot/core@master] (Re)move unused code reoprted by vulture

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

Change 475341 had a related patch set uploaded (by Arcayn; owner: Arcayn):
[pywikibot/core@master] [bugfix] Fix redirect.py editing same redirect page twice

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

Change 475342 had a related patch set uploaded (by Arcayn; owner: Arcayn):
[pywikibot/core@master] [cleanup] Remove unused code in 1 script

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

Change 475109 abandoned by Arcayn:
[cleanup] remove unused code in 2 scripts

Reason:
Superseded by

https://gerrit.wikimedia.org/r/475341
and
https://gerrit.wikimedia.org/r/475342

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

Change 475342 merged by jenkins-bot:
[pywikibot/core@master] [cleanup] Remove unused code in 1 script

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

Change 474727 merged by jenkins-bot:
[pywikibot/core@master] [cleanup] Remove unused code in 4 files

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

Change 477467 had a related patch set uploaded (by YVB; owner: YVB):
[pywikibot/core@master] [Cleanup] Remove unused variables in tests\deprecation_tests.py

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

Change 477947 had a related patch set uploaded (by YVB; owner: YVB):
[pywikibot/core@master] [Cleanup] Remove unused variables and unreachanble code

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

Change 477467 merged by jenkins-bot:
[pywikibot/core@master] [Cleanup] Remove unused variables in tests\deprecation_tests.py

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

Change 477947 merged by jenkins-bot:
[pywikibot/core@master] [Cleanup] Remove unused variables and unreachanble code

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

Dvorapa updated the task description. (Show Details)

Change 487083 had a related patch set uploaded (by Mahveotm; owner: Mahveotm):
[pywikibot/core@master] [cleanup] removed unused variabe in pywikibot

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

Seems the remaining code parts are false positives

Change 487083 abandoned by Mahveotm:
[cleanup] removed unused variabe in pywikibot

Reason:
false positives.

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

There are some others in T214993: Deprecate possibly unused code reported in 60% confidence by Vulture, but one have to be careful and know, what he is doing in 60% confidence...