Showing 20 of 20 total issues

Class Archive has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Archive
    include Serializable

    def self.from_string(str, uri = nil)
      new JSON.parse(str), uri
Severity: Minor
Found in lib/har/archive.rb - About 2 hrs to fix

    File harSchema.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* See license.txt for terms of usage */
    
    define("preview/harSchema", [], function() {
    
    // ************************************************************************************************
    Severity: Minor
    Found in lib/har/viewer/scripts/preview/harSchema.js - About 2 hrs to fix

      File domplate.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      
      define("domplate/domplate",[],function(){Domplate={};(function(){function DomplateTag(tagName)
      {this.tagName=tagName;}
      this.DomplateTag=DomplateTag;function DomplateEmbed()
      {}
      Severity: Minor
      Found in lib/har/viewer/scripts/domplate/domplate.js - About 2 hrs to fix

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

        var cacheType = {
            "cacheType": {
                "id": "cacheType",
                "description": "Info about a response coming from the cache.",
                "properties": {
        Severity: Major
        Found in lib/har/viewer/scripts/preview/harSchema.js and 1 other location - About 1 hr to fix
        lib/har/viewer/scripts/preview/harSchema.js on lines 128..138

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

        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

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

        var recordType = {
            "recordType": {
                "id": "recordType",
                "description": "Helper name-value pair structure.",
                "properties": {
        Severity: Major
        Found in lib/har/viewer/scripts/preview/harSchema.js and 1 other location - About 1 hr to fix
        lib/har/viewer/scripts/preview/harSchema.js on lines 215..225

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

        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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        {var partName=part.name;if(part.format)
        {for(var j=0;j<part.format.length;++j)
        partName=part.format[j]+"("+partName+")";}
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 2 other locations - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 149..151
        lib/har/viewer/scripts/domplate/domplate.js on lines 185..187

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

        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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        {var varName='d'+path.renderIndex++;if(part.format)
        {for(var j=0;j<part.format.length;++j)
        varName=part.format[j]+'('+varName+')';}
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 2 other locations - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 149..151
        lib/har/viewer/scripts/domplate/domplate.js on lines 198..200

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

        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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        {var part=this.iter.parts[0];iterName=part.name;if(part.format)
        {for(var i=0;i<part.format.length;++i)
        iterName=part.format[i]+"("+iterName+")";}}
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 2 other locations - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 185..187
        lib/har/viewer/scripts/domplate/domplate.js on lines 198..200

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

        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

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

        var offset=0;if(this.tag.isLoop)
        {var node=firstRow.parentNode.firstChild;for(;node&&node!=firstRow;node=node.nextSibling)
        ++offset;}
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 1 other location - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 257..259

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

        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

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

        parent.appendChild(womb.firstChild);var offset=0;if(this.tag.isLoop)
        {var node=firstCol.parentNode.firstChild;for(;node&&node!=firstCol;node=node.nextSibling)
        ++offset;}
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 1 other location - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 238..240

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

        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

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

        else if(name.indexOf("$")==0)
        {var className=name.substr(1);if(!this.classes)
        this.classes={};this.classes[className]=val;}
        else
        {if(name=="class"&&name in this.attrs)
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 1 other location - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 28..37

        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

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

        else if(name.indexOf("_")==0)
        {var propName=name.substr(1);if(!this.props)
        this.props={};this.props[propName]=val;}
        else if(name.indexOf("$")==0)
        {var className=name.substr(1);if(!this.classes)
        Severity: Major
        Found in lib/har/viewer/scripts/domplate/domplate.js and 1 other location - About 1 hr to fix
        lib/har/viewer/scripts/domplate/domplate.js on lines 31..37

        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 compileDOM has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        continue;map[name]=1;var names=name.split(".");blocks.push('var ',names[0]+' = '+'__in__.'+names[0]+';\n');}},compileDOM:function()
        {var path=[];var blocks=[];this.domArgs=[];path.embedIndex=0;path.loopIndex=0;path.staticIndex=0;path.renderIndex=0;var nodeCount=this.generateDOM(path,blocks,this.domArgs);var fnBlock=['(function (root, context, o'];for(var i=0;i<path.staticIndex;++i)
        fnBlock.push(', ','s'+i);for(var i=0;i<path.renderIndex;++i)
        fnBlock.push(', ','d'+i);fnBlock.push(') {\n');for(var i=0;i<path.loopIndex;++i)
        fnBlock.push('var l',i,' = 0;\n');for(var i=0;i<path.embedIndex;++i)
        Severity: Minor
        Found in lib/har/viewer/scripts/domplate/domplate.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

          {var className=name.substr(1);if(!this.classes)
          this.classes={};this.classes[className]=val;}
          Severity: Major
          Found in lib/har/viewer/scripts/domplate/domplate.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

            {for(var j=0;j<part.format.length;++j)
            partName=part.format[j]+"("+partName+")";}
            Severity: Major
            Found in lib/har/viewer/scripts/domplate/domplate.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

              {if(name=="class"&&name in this.attrs)
              this.attrs[name]+=" "+val;else
              this.attrs[name]=val;}}},compile:function()
              Severity: Major
              Found in lib/har/viewer/scripts/domplate/domplate.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                {for(var j=0;j<part.format.length;++j)
                varName=part.format[j]+'('+varName+')';}
                Severity: Major
                Found in lib/har/viewer/scripts/domplate/domplate.js - About 45 mins to fix

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

                  function addParts(val,delim,block,info,escapeIt)
                  Severity: Minor
                  Found in lib/har/viewer/scripts/domplate/domplate.js - About 35 mins to fix

                    Method by_merging has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def self.by_merging(hars)
                          hars = hars.dup
                    
                          result = hars.shift or raise ArgumentError, "no HARs given"
                          result = from_file(result) unless result.kind_of? self
                    Severity: Minor
                    Found in lib/har/archive.rb - About 25 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

                    Method validate_if_needed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def validate_if_needed(hars)
                          return hars unless @options[:validate]
                    
                          progress("Validating archives...") {
                            Array(hars).map { |har|
                    Severity: Minor
                    Found in lib/har/viewer.rb - About 25 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