DRY and style issues

Bug #1430342 reported by Full Decent on 2015-03-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
JessyInk
Undecided
Unassigned

Bug Description

Several issues are reported by Code Climate regarding duplicate code and styling issues. It may be nice to fix these.

  * https://codeclimate.com/github/inkscape/inkscape/inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_noclick.js
  * https://codeclimate.com/github/inkscape/inkscape/inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js

For posterity, the issues are copy/pasted below:

======================
share/extensions/jessyInk_core_mouseHandler_noclick.js

Similar code found in two :function_declaration nodes (mass = 82)

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_noclick.js:22…29 < >

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:22…29 < >

Expected '===' and instead saw '=='. (Line 28)

if (elems[counter].getAttributeNS("https://launchpad.net/jessyink", "subtype") == "jessyInk_core_mouseHandler_noclick")
Expected '{' and instead saw 'jessyInk_core_mouseHandler_noclick'. (Line 29)

jessyInk_core_mouseHandler_noclick(elems[counter]);
The object literal notation {} is preferable. (Line 45)

var handlerDictio = new Object();
The object literal notation {} is preferable. (Line 47)

handlerDictio[SLIDE_MODE] = new Object();
Missing semicolon. (Line 51)

}
'SLIDE_MODE' is not defined. (Line 47)

handlerDictio[SLIDE_MODE] = new Object();
'SLIDE_MODE' is not defined. (Line 48)

handlerDictio[SLIDE_MODE][MOUSE_DOWN] = null;
'MOUSE_DOWN' is not defined. (Line 48)

handlerDictio[SLIDE_MODE][MOUSE_DOWN] = null;

===============
share/extensions/jessyInk_core_mouseHandler_zoomControl.js

Complex method .mouseclick (complexity = 26)

    obj.mouseclick = function (e)
    {
        var elem = obj.getAdHocViewBbox(slides[activeSlide]["viewGroup"], obj.getCoords(e));

        processingEffect = true;
View more
Complex method .rectToMatrix (complexity = 24)

    obj.rectToMatrix = function(rect)
    {
        rectWidth = rect.getBBox().width;
        rectHeight = rect.getBBox().height;
        rectX = rect.getBBox().x;
View more
Identical code found in two :block_statement nodes (mass*2 = 724)

inkscape-launchpad/share/extensions/jessyInk.js:2347…2383 < >

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:383…419 < >

Identical code found in two :if_statement nodes (mass*2 = 220)

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:240…246 < >

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:322…328 < >

Similar code found in two :function_declaration nodes (mass = 82)

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_noclick.js:22…29 < >

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:22…29 < >

Similar code found in three :logical_expression nodes (mass = 84)

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:212 < >

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:214 < >

inkscape-launchpad/share/extensions/jessyInk_core_mouseHandler_zoomControl.js:216 < >

Expected '===' and instead saw '=='. (Line 28)

if (elems[counter].getAttributeNS("https://launchpad.net/jessyink", "subtype") == "jessyInk_core_mouseHandler_zoomControl")
Expected '{' and instead saw 'jessyInk_core_mouseHandler_zoomControl'. (Line 29)

jessyInk_core_mouseHandler_zoomControl(elems[counter]);
Expected an assignment or function call and instead saw an expression. (Line 40)

obj.dragging_last;
The object literal notation {} is preferable. (Line 54)

var handlerDictio = new Object();
The object literal notation {} is preferable. (Line 56)

handlerDictio[SLIDE_MODE] = new Object();
Missing semicolon. (Line 63)

}
['viewGroup'] is better written in dot notation. (Line 71)

var elem = obj.getAdHocViewBbox(slides[activeSlide]["viewGroup"], obj.getCoords(e));
The array literal notation [] is preferable. (Line 75)

effectArray = new Array();
The object literal notation {} is preferable. (Line 77)

effectArray[0] = new Object();
['effect'] is better written in dot notation. (Line 78)

effectArray[0]["effect"] = "view";
['dir'] is better written in dot notation. (Line 79)

effectArray[0]["dir"] = 1;
['element'] is better written in dot notation. (Line 80)

effectArray[0]["element"] = slides[activeSlide]["viewGroup"];
['viewGroup'] is better written in dot notation. (Line 80)

effectArray[0]["element"] = slides[activeSlide]["viewGroup"];
['options'] is better written in dot notation. (Line 81)

effectArray[0]["options"] = new Object();
The object literal notation {} is preferable. (Line 81)

effectArray[0]["options"] = new Object();
['options'] is better written in dot notation. (Line 82)

effectArray[0]["options"]["length"] = 200;
['length'] is better written in dot notation. (Line 82)

effectArray[0]["options"]["length"] = 200;
Expected '===' and instead saw '=='. (Line 84)

if (elem == null)
Expected '{' and instead saw 'effectArray'. (Line 85)

effectArray[0]["options"]["matrixNew"] = (new matrixSVG()).fromSVGElements(1, 0, 0, 1, 0, 0);
['options'] is better written in dot notation. (Line 85)

effectArray[0]["options"]["matrixNew"] = (new matrixSVG()).fromSVGElements(1, 0, 0, 1, 0, 0);
['matrixNew'] is better written in dot notation. (Line 85)

effectArray[0]["options"]["matrixNew"] = (new matrixSVG()).fromSVGElements(1, 0, 0, 1, 0, 0);
A constructor name should start with an uppercase letter. (Line 85)

effectArray[0]["options"]["matrixNew"] = (new matrixSVG()).fromSVGElements(1, 0, 0, 1, 0, 0);
Expected '{' and instead saw 'effectArray'. (Line 87)

effectArray[0]["options"]["matrixNew"] = obj.pointMatrixToTransformation(obj.rectToMatrix(elem)).mult((new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.getScreenCTM()).inv().mult((new matrixSVG()).fromSVGMatrix(elem.parentNode.getScreenCTM())).inv());
['options'] is better written in dot notation. (Line 87)

effectArray[0]["options"]["matrixNew"] = obj.pointMatrixToTransformation(obj.rectToMatrix(elem)).mult((new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.getScreenCTM()).inv().mult((new matrixSVG()).fromSVGMatrix(elem.parentNode.getScreenCTM())).inv());
['matrixNew'] is better written in dot notation. (Line 87)

effectArray[0]["options"]["matrixNew"] = obj.pointMatrixToTransformation(obj.rectToMatrix(elem)).mult((new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.getScreenCTM()).inv().mult((new matrixSVG()).fromSVGMatrix(elem.parentNode.getScreenCTM())).inv());
A constructor name should start with an uppercase letter. (Line 87)

effectArray[0]["options"]["matrixNew"] = obj.pointMatrixToTransformation(obj.rectToMatrix(elem)).mult((new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.getScreenCTM()).inv().mult((new matrixSVG()).fromSVGMatrix(elem.parentNode.getScreenCTM())).inv());
A constructor name should start with an uppercase letter. (Line 87)

effectArray[0]["options"]["matrixNew"] = obj.pointMatrixToTransformation(obj.rectToMatrix(elem)).mult((new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.getScreenCTM()).inv().mult((new matrixSVG()).fromSVGMatrix(elem.parentNode.getScreenCTM())).inv());
Missing semicolon. (Line 95)

}
['element'] is better written in dot notation. (Line 123)

var screenPointList = obj.projectRect(viewBbox, slides[activeSlide]["element"].getScreenCTM());
Expected '{' and instead saw 'return'. (Line 126)

return children[counter];
Expected '!==' and instead saw '!='. (Line 130)

if (child != null)
Expected '{' and instead saw 'return'. (Line 131)

return child;
Missing semicolon. (Line 136)

}
Missing semicolon. (Line 167)

}
A constructor name should start with an uppercase letter. (Line 181)

var matrixOrig = (new matrixSVG()).fromElements(pntUL.x, pntLL.x, pntUR.x, pntUL.y, pntLL.y, pntUR.y, 1, 1, 1);
A constructor name should start with an uppercase letter. (Line 182)

var matrixProj = (new matrixSVG()).fromElements(0, 0, 1, 0, 1, 0, 1, 1, 1);
The array literal notation [] is preferable. (Line 188)

var subPnts = new Array();
Expected '{' and instead saw 'subPnts'. (Line 193)

subPnts[pntCounter] = pnts[blockCounter * 3.0 + pntCounter];
A constructor name should start with an uppercase letter. (Line 205)

var matrixPnt = (new matrixSVG).fromElements(subPnts[0].x, subPnts[1].x, subPnts[2].x, subPnts[0].y, subPnts[1].y, subPnts[2].y, 1, 1, 1);
Missing '()' invoking a constructor. (Line 205)

var matrixPnt = (new matrixSVG).fromElements(subPnts[0].x, subPnts[1].x, subPnts[2].x, subPnts[0].y, subPnts[1].y, subPnts[2].y, 1, 1, 1);
'pntCounter' is already defined. (Line 208)

for (var pntCounter = 0; pntCounter < 3.0; pntCounter++)
Expected '===' and instead saw '=='. (Line 212)

if ((pntCounter == 0) && !((matrixTrans.e11 > 0.01) && (matrixTrans.e11 < 0.99) && (matrixTrans.e21 > 0.01) && (matrixTrans.e21 < 0.99)))
Expected '{' and instead saw 'return'. (Line 213)

return false;
Expected '===' and instead saw '=='. (Line 214)

else if ((pntCounter == 1) && !((matrixTrans.e12 > 0.01) && (matrixTrans.e12 < 0.99) && (matrixTrans.e22 > 0.01) && (matrixTrans.e22 < 0.99)))
Expected '{' and instead saw 'return'. (Line 215)

return false;
Expected '===' and instead saw '=='. (Line 216)

else if ((pntCounter == 2) && !((matrixTrans.e13 > 0.01) && (matrixTrans.e13 < 0.99) && (matrixTrans.e23 > 0.01) && (matrixTrans.e23 < 0.99)))
Expected '{' and instead saw 'return'. (Line 217)

return false;
Missing semicolon. (Line 223)

}
Expected '{' and instead saw 'return'. (Line 234)

return false;
A constructor name should start with an uppercase letter. (Line 242)

var matrix = (new matrixSVG()).fromElements(1, 0, 0, 0, 1, 0, 0, 0, 1);
Too many errors. (55% scanned). (Line 242)

var matrix = (new matrixSVG()).fromElements(1, 0, 0, 0, 1, 0, 0, 0, 1);

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers