CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/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];

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;
        

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 = {};
        }

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 = {};
        }

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

      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;
              

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

            SWFUpload.prototype.initSettings = (function (oldInitSettings) {
                return function () {
                    if (typeof(oldInitSettings) === "function") {
                        oldInitSettings.call(this);
                    }

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

              SWFUpload.prototype.initSettings = (function (oldInitSettings) {
                  return function () {
                      if (typeof(oldInitSettings) === "function") {
                          oldInitSettings.call(this);
                      }

          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);
              
              };
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.speed.js on lines 272..276
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.speed.js on lines 282..286

          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);
              
              };
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.speed.js on lines 272..276
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.speed.js on lines 277..281

          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);
              
              };
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.speed.js on lines 277..281
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.speed.js on lines 282..286

          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] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
                      };
          Web.Admin/2014/wordpress/wp-includes/js/swfupload/plugins/swfupload.swfobject.js on lines 59..61

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

          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