talho/openphin

View on GitHub
app/assets/javascripts/ext/src/widgets/chart/swfobject.js

Summary

Maintainability
F
2 wks
Test Coverage

Function swfobject has a Cognitive Complexity of 428 (exceeds 5 allowed). Consider refactoring.
Open

var swfobject = function() {
    
    var UNDEF = "undefined",
        OBJECT = "object",
        SHOCKWAVE_FLASH = "Shockwave Flash",
Severity: Minor
Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 wk 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 swfobject has 663 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var swfobject = function() {
    
    var UNDEF = "undefined",
        OBJECT = "object",
        SHOCKWAVE_FLASH = "Shockwave Flash",
Severity: Major
Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 3 days to fix

    File swfobject.js has 665 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * Ext JS Library 3.3.0
     * Copyright(c) 2006-2010 Ext JS, Inc.
     * licensing@extjs.com
     * http://www.extjs.com/license
    Severity: Major
    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 day to fix

      Function createSWF has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function createSWF(attObj, parObj, id) {
              var r, el = getElementById(id);
              if (ua.wk && ua.wk < 312) { return r; }
              if (el) {
                  if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
      Severity: Major
      Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 2 hrs to fix

        Function matchVersions has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function matchVersions() {
                var rl = regObjArr.length;
                if (rl > 0) {
                    for (var i = 0; i < rl; i++) { // for each registered object element
                        var id = regObjArr[i].id;
        Severity: Major
        Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 2 hrs to fix

          Function embedSWF has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
                      var callbackObj = {success:false, id:replaceElemIdStr};
                      if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
                          setVisibility(replaceElemIdStr, false);
                          addDomLoadEvent(function() {
          Severity: Major
          Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 2 hrs to fix

            Function showExpressInstall has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
                    isExpressInstallActive = true;
                    storedCallbackFn = callbackFn || null;
                    storedCallbackObj = {success:false, id:replaceElemIdStr};
                    var obj = getElementById(replaceElemIdStr);
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

              Function onDomLoad has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  onDomLoad = function() {
                      if (!ua.w3) { return; }
                      if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically 
                          callDomLoadFunctions();
                      }
              Severity: Minor
              Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

                Function ua has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    ua = function() {
                        var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
                            u = nav.userAgent.toLowerCase(),
                            p = nav.platform.toLowerCase(),
                            windows = p ? (/win/).test(p) : /win/.test(u),
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
                                  setVisibility(replaceElemIdStr, false);
                                  addDomLoadEvent(function() {
                                      widthStr += ""; // auto-convert to string
                                      heightStr += "";
                  Severity: Critical
                  Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

                    Function embedSWF has 10 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
                    Severity: Major
                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

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

                          function createCSS(sel, decl, media, newStyle) {
                              if (ua.ie && ua.mac) { return; }
                              var h = doc.getElementsByTagName("head")[0];
                              if (!h) { return; } // to also support badly authored HTML pages that lack a head element
                              var m = (media && typeof media == "string") ? media : "screen";
                      Severity: Minor
                      Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

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

                            function testPlayerVersion() {
                                var b = doc.getElementsByTagName("body")[0];
                                var o = createElement(OBJECT);
                                o.setAttribute("type", FLASH_MIME_TYPE);
                                var t = b.appendChild(o);
                        Severity: Minor
                        Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 1 hr to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if (o && typeof o.SetVariable != UNDEF) { 
                                                      cbObj.success = true;
                                                      cbObj.ref = o;
                                                  }
                          Severity: Major
                          Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (i.toLowerCase() == "data") {
                                                        parObj.movie = attObj[i];
                                                    }
                                                    else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
                                                        att += ' class="' + attObj[i] + '"';
                            Severity: Major
                            Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
                                                          setVisibility(id, true);
                                                          if (cb) {
                                                              cbObj.success = true;
                                                              cbObj.ref = getObjectById(id);
                              Severity: Major
                              Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
                                                            ac.appendChild(c[i].cloneNode(true));
                                                        }
                                Severity: Major
                                Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
                                                              o.setAttribute("class", attObj[m]);
                                                          }
                                                          else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
                                                              o.setAttribute(m, attObj[m]);
                                  Severity: Major
                                  Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js - About 45 mins to fix

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

                                                if (typeof att.height == UNDEF || (!(/%$/).test(att.height) && parseInt(att.height, 10) < 137)) {
                                                    att.height = "137";
                                                }
                                    Severity: Major
                                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js and 1 other location - About 1 hr to fix
                                    app/assets/javascripts/ext/src/widgets/chart/swfobject.js on lines 333..335

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

                                    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

                                                if (typeof att.width == UNDEF || (!(/%$/).test(att.width) && parseInt(att.width, 10) < 310)) {
                                                    att.width = "310";
                                                }
                                    Severity: Major
                                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js and 1 other location - About 1 hr to fix
                                    app/assets/javascripts/ext/src/widgets/chart/swfobject.js on lines 337..339

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

                                    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

                                                (function(){
                                                    if (obj.readyState == 4) {
                                                        obj.parentNode.removeChild(obj);
                                                    }
                                                    else {
                                    Severity: Major
                                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js and 1 other location - About 1 hr to fix
                                    app/assets/javascripts/ext/src/widgets/chart/swfobject.js on lines 357..364

                                    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

                                                    (function(){
                                                        if (obj.readyState == 4) {
                                                            obj.parentNode.removeChild(obj);
                                                        }
                                                        else {
                                    Severity: Major
                                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js and 1 other location - About 1 hr to fix
                                    app/assets/javascripts/ext/src/widgets/chart/swfobject.js on lines 380..387

                                    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

                                                        if (parObj && typeof parObj === OBJECT) {
                                                            for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
                                                                par[j] = parObj[j];
                                                            }
                                                        }
                                    Severity: Minor
                                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js and 1 other location - About 35 mins to fix
                                    app/assets/javascripts/ext/src/widgets/chart/swfobject.js on lines 666..670

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

                                    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

                                                        if (attObj && typeof attObj === OBJECT) {
                                                            for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
                                                                att[i] = attObj[i];
                                                            }
                                                        }
                                    Severity: Minor
                                    Found in app/assets/javascripts/ext/src/widgets/chart/swfobject.js and 1 other location - About 35 mins to fix
                                    app/assets/javascripts/ext/src/widgets/chart/swfobject.js on lines 675..679

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

                                    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