throrin19/svgutils

View on GitHub

Showing 44 of 105 total issues

Function fromNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.fromNode = function fromNode(node){
    var text = new Tspan();

    if(typeof node != 'undefined'){

Severity: Minor
Found in libs/objects/tspan.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function toJSON has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

SvgObject.prototype.toJSON = function toJSON(matrix){

    var json = {
        type : this.type
    };
Severity: Minor
Found in libs/objects/svgobject.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function fromNode has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.fromNode = function fromNode(object, node){
    if(typeof node != 'undefined' && typeof node.$ != 'undefined'){
        if(typeof node.$['class'] != 'undefined'){
            object.setClassesFromString(node.$['class']);
        }
Severity: Minor
Found in libs/objects/svgobject.js - About 1 hr to fix

    Function calculateAllInnerBoxes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Svg.prototype.calculateAllInnerBoxes = function calculateAllInnerBoxes(callback) {
        var svg = new Svg();
        async.each(this.elements, function (child, done) {
            switch (child.type) {
                case 'rect' :
    Severity: Minor
    Found in libs/svg.js - About 1 hr to fix

      Function is has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          is : function(o, type) {
              type = Str.prototype.toLowerCase.call(type);
              if (type == "finite") {
                  return isFinite(o);
              }
      Severity: Minor
      Found in libs/matrix/utils.js - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function parseJson has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Parser.parseJson = function parseJson(elements) {
          var nodes = [];
      
          _.each(elements, function (element) {
              switch (element.type) {
      Severity: Minor
      Found in libs/parser.js - About 1 hr to fix

        Function parseXmlNode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Parser.parseXmlNode = function parseXmlNode(node) {
            var nodes = [];
        
            _.each(node, function (content, index) {
                switch (index) {
        Severity: Minor
        Found in libs/parser.js - About 1 hr to fix

          Function fromElement has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports.fromElement = function(bbox, element){
              if(typeof element.transform != 'undefined'){
                  var tstr = element.transform;
          
                  var res = [];
          Severity: Minor
          Found in libs/matrix/extends.js - About 1 hr to fix

            Function toXml has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            SvgObject.prototype.toXml = function toXml(matrix){
                var xml = builder.create(this.type);
            
                var style = "";
                _.each(this.style, function(value, index){
            Severity: Minor
            Found in libs/objects/svgobject.js - About 1 hr to fix

              Function fromJson has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.fromJson = function fromJson(object, json){
                  if(typeof json != 'undefined'){
                      if(typeof json.classes != 'undefined'){
                          object.classes = json.classes;
                      }
              Severity: Minor
              Found in libs/objects/svgobject.js - About 1 hr to fix

                Function bbox has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    bbox : function(x, y, width, height) {
                        if (x == null) {
                            x = y = width = height = 0;
                        }
                        if (y == null) {
                Severity: Minor
                Found in libs/matrix/utils.js - About 1 hr to fix

                  Function fromNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports.fromNode = function fromNode(node) {
                      var image = new Img();
                  
                      if (typeof node !== 'undefined' && typeof node.$ !== 'undefined') {
                          SvgObject.fromNode(image, node);
                  Severity: Minor
                  Found in libs/objects/image.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if (tlen == 2) {
                                            bb = bb || bbox;
                                            m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);
                                        } else if (tlen == 4) {
                                            if (absolute) {
                    Severity: Major
                    Found in libs/matrix/utils.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      } else if (command == "s") {
                                          if (tlen == 2 || tlen == 3) {
                                              bb = bb || bbox;
                                              m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);
                                          } else if (tlen == 4) {
                      Severity: Major
                      Found in libs/matrix/utils.js - About 45 mins to fix

                        Function add has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            matrixproto.add = function (a, b, c, d, e, f) {
                        Severity: Minor
                        Found in libs/matrix/matrix.js - About 45 mins to fix

                          Function fromNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          module.exports.fromNode = function fromNode(node) {
                              var circle = new Circle();
                          
                              if (typeof node !== 'undefined' && typeof node.$ !== 'undefined') {
                                  SvgObject.fromNode(circle, node);
                          Severity: Minor
                          Found in libs/objects/circle.js - About 45 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Function Matrix has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function Matrix(a, b, c, d, e, f) {
                          Severity: Minor
                          Found in libs/matrix/matrix.js - About 45 mins to fix

                            Function rectPath has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                rectPath : function(x, y, w, h, r) {
                            Severity: Minor
                            Found in libs/matrix/utils.js - About 35 mins to fix

                              Function removeByType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              Svg.prototype.removeByType = function removeByType(params) {
                                  this.elements = _.filter(this.elements, function (element) {
                                      if (!_.isArray(params.type)) {
                                          var t = params.type;
                                          params.type = [];
                              Severity: Minor
                              Found in libs/svg.js - About 35 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function removeByType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              Group.prototype.removeByType = function removeByType(params) {
                                  this.childs = _.filter(this.childs, function (element) {
                                      if (!_.isArray(params.type)) {
                                          var t = params.type;
                                          params.type = [];
                              Severity: Minor
                              Found in libs/objects/group.js - About 35 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Severity
                              Category
                              Status
                              Source
                              Language