throrin19/svgutils

View on GitHub

Showing 105 of 105 total issues

Function contains has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

SvgObject.prototype.contains = function contains(svgObject, callback){
    var self = this;
    async.parallel({
        ownBbox : function(c){
            self.getBBox(function(bbox){
Severity: Minor
Found in libs/objects/svgobject.js - About 1 hr to fix

    Function fromJson has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.fromJson = function fromJson(json){
        var rect = new Rect();
    
        if(typeof json != 'undefined'){
            SvgObject.fromJson(rect, json);
    Severity: Minor
    Found in libs/objects/rect.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 fromJson has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.fromJson = function fromJson(json){
        var image = new Img();
    
        if (typeof json != 'undefined') {
            SvgObject.fromJson(image, json);
    Severity: Minor
    Found in libs/objects/image.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 _widestSegmentAtY has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Polygon.prototype._widestSegmentAtY = function _widestSegmentAtY(y) {
        var segment = {
                x : 0,
                y : y,
                width : 0
    Severity: Minor
    Found in libs/objects/polygon.js - About 1 hr to fix

      Function fromJson has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.fromJson = function fromJson(json){
          var text = new Text();
      
          if(typeof json != 'undefined'){
              SvgObject.fromJson(text, json);
      Severity: Minor
      Found in libs/objects/text.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 calculateAllInnerBoxes has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Group.prototype.calculateAllInnerBoxes = function calculateAllInnerBoxes(callback) {
          var group = new Group();
          group.style   = this.style;
          group.classes = this.classes;
          group.id      = this.id;
      Severity: Minor
      Found in libs/objects/group.js - About 1 hr to fix

        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 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 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 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 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 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 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

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                              return "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")";
                      Severity: Major
                      Found in libs/matrix/matrix.js and 1 other location - About 1 hr to fix
                      libs/matrix/matrix.js on lines 263..263

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 56.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                                  return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
                      Severity: Major
                      Found in libs/matrix/matrix.js and 1 other location - About 1 hr to fix
                      libs/matrix/matrix.js on lines 180..180

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 56.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      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
                          Severity
                          Category
                          Status
                          Source
                          Language