jkuchar/MultipleFileUpload

View on GitHub
public/swfupload/js/swfupload.speed.js

Summary

Maintainability
D
2 days
Test Coverage

Function formatUnits has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    SWFUpload.speed.formatUnits = function (baseNumber, unitDivisors, unitLabels, singleFractional) {
        var i, unit, unitDivisor, unitLabel;

        if (baseNumber === 0) {
            return "0 " + unitLabels[unitLabels.length - 1];
Severity: Minor
Found in public/swfupload/js/swfupload.speed.js - About 5 hrs 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 calculateMovingAverage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    SWFUpload.speed.calculateMovingAverage = function (history) {
        var vals = [], size, sum = 0.0, mean = 0.0, varianceTemp = 0.0, variance = 0.0, standardDev = 0.0;
        var i;
        var mSum = 0, mCount = 0;
        
Severity: Minor
Found in public/swfupload/js/swfupload.speed.js - About 3 hrs 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 updateTracking has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    SWFUpload.prototype.updateTracking = function (file, bytesUploaded) {
        var tracking = this.fileSpeedStats[file.id];
        if (!tracking) {
            this.fileSpeedStats[file.id] = tracking = {};
        }
Severity: Minor
Found in public/swfupload/js/swfupload.speed.js - About 2 hrs 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 updateTracking has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    SWFUpload.prototype.updateTracking = function (file, bytesUploaded) {
        var tracking = this.fileSpeedStats[file.id];
        if (!tracking) {
            this.fileSpeedStats[file.id] = tracking = {};
        }
Severity: Minor
Found in public/swfupload/js/swfupload.speed.js - About 1 hr to fix

    Function formatUnits has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        SWFUpload.speed.formatUnits = function (baseNumber, unitDivisors, unitLabels, singleFractional) {
            var i, unit, unitDivisor, unitLabel;
    
            if (baseNumber === 0) {
                return "0 " + unitLabels[unitLabels.length - 1];
    Severity: Minor
    Found in public/swfupload/js/swfupload.speed.js - About 1 hr to fix

      Function calculateMovingAverage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          SWFUpload.speed.calculateMovingAverage = function (history) {
              var vals = [], size, sum = 0.0, mean = 0.0, varianceTemp = 0.0, variance = 0.0, standardDev = 0.0;
              var i;
              var mSum = 0, mCount = 0;
              
      Severity: Minor
      Found in public/swfupload/js/swfupload.speed.js - About 1 hr to fix

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

            SWFUpload.prototype.initSettings = (function (oldInitSettings) {
                return function (userSettings) {
                    if (typeof(oldInitSettings) === "function") {
                        oldInitSettings.call(this, userSettings);
                    }
        Severity: Minor
        Found in public/swfupload/js/swfupload.speed.js - About 1 hr to fix

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

              SWFUpload.prototype.initSettings = (function (oldInitSettings) {
                  return function (userSettings) {
                      if (typeof(oldInitSettings) === "function") {
                          oldInitSettings.call(this, userSettings);
                      }
          Severity: Minor
          Found in public/swfupload/js/swfupload.speed.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 extendFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              SWFUpload.speed.extendFile = function (file, trackingList) {
                  var tracking;
                  
                  if (!file) {
                      return file;
          Severity: Minor
          Found in public/swfupload/js/swfupload.speed.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

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

              SWFUpload.speed.formatTime = function (baseNumber) {
                  var timeUnits = [86400, 3600, 60, 1], timeUnitLabels = ["d", "h", "m", "s"];
                  return SWFUpload.speed.formatUnits(baseNumber, timeUnits, timeUnitLabels, false);
              
              };
          Severity: Major
          Found in public/swfupload/js/swfupload.speed.js and 2 other locations - About 1 hr to fix
          public/swfupload/js/swfupload.speed.js on lines 276..280
          public/swfupload/js/swfupload.speed.js on lines 286..290

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

          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

              SWFUpload.speed.formatBPS = function (baseNumber) {
                  var bpsUnits = [1073741824, 1048576, 1024, 1], bpsUnitLabels = ["Gbps", "Mbps", "Kbps", "bps"];
                  return SWFUpload.speed.formatUnits(baseNumber, bpsUnits, bpsUnitLabels, true);
              
              };
          Severity: Major
          Found in public/swfupload/js/swfupload.speed.js and 2 other locations - About 1 hr to fix
          public/swfupload/js/swfupload.speed.js on lines 281..285
          public/swfupload/js/swfupload.speed.js on lines 286..290

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

          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

              SWFUpload.speed.formatBytes = function (baseNumber) {
                  var sizeUnits = [1073741824, 1048576, 1024, 1], sizeUnitLabels = ["GB", "MB", "KB", "bytes"];
                  return SWFUpload.speed.formatUnits(baseNumber, sizeUnits, sizeUnitLabels, true);
              
              };
          Severity: Major
          Found in public/swfupload/js/swfupload.speed.js and 2 other locations - About 1 hr to fix
          public/swfupload/js/swfupload.speed.js on lines 276..280
          public/swfupload/js/swfupload.speed.js on lines 281..285

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

          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

                      this.ensureDefault = function (settingName, defaultValue) {
                          this.settings[settingName] = (userSettings[settingName] == undefined) ? defaultValue : userSettings[settingName];
                      };
          Severity: Minor
          Found in public/swfupload/js/swfupload.speed.js and 1 other location - About 55 mins to fix
          public/swfupload/js/swfupload.proxy.js on lines 30..32

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

          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

          There are no issues that match your filters.

          Category
          Status