Page MenuHomePhabricator

Avoid code duplication and non-executed code from CXCategoryTool.prototype.getCategories
Closed, ResolvedPublic1 Estimated Story Points

Description

ContentTranslation (master)$ ack ".getCategories"
tests/qunit/tools/ext.cx.tools.categories.test.js
28:                     mw.cx.categoryTool.getCategories( 'source' )
73:                     mw.cx.categoryTool.getCategories( 'adapted' )
113:            function testGetTargetCategories( title ) {
118:                    mw.cx.categoryTool.getCategories( 'target' )
127:            testGetTargetCategories( 'Han Fei' )
136:            testGetTargetCategories( 'Han' )
145:            testGetTargetCategories( 'Shen Dao' )

modules/tools/ext.cx.tools.categories.js
607:    CXCategoryTool.prototype.getCategories = function ( categorySet ) {
724:            mw.cx.categoryTool.getCategories().done( function ( categories ) {

This shows that getCategories is always called without parameters from user interface.
But CXCategoryTool.prototype.getCategories expect category set and there are 4 cases for category set. Only the 'default' case is actually used in the user interface. Rest of them serves only unit test cases.

Please do not test the code that is never executed outside test and remove the non-executed code. Rewrite the tests accordingly.

Event Timeline

santhosh assigned this task to Jsahleen.
santhosh raised the priority of this task from to Medium.
santhosh updated the task description. (Show Details)
santhosh subscribed.
santhosh renamed this task from Avoid code duplication and unwanted code from CXCategoryTool.prototype.getCategories to Avoid code duplication and non-executed code from CXCategoryTool.prototype.getCategories.Feb 16 2015, 2:40 PM
santhosh updated the task description. (Show Details)
santhosh set Security to None.

Change 191673 had a related patch set uploaded (by Jsahleen):
[WIP] Categories: Update categories code and unit tests

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

Patch-For-Review

Change 191673 merged by jenkins-bot:
Categories: Update categories code and unit tests

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

santhosh raised the priority of this task from Medium to High.Feb 23 2015, 7:09 AM
santhosh moved this task from In Review to Done on the LE-Sprint-82 board.