alain-andre/alain-andre-fr

View on GitHub
source/javascripts/libs/swfobject-dynamic.js

Summary

Maintainability
F
3 wks
Test Coverage

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

var swfobject = function() {

    var UNDEF = "undefined",
        OBJECT = "object",
        SHOCKWAVE_FLASH = "Shockwave Flash",
Severity: Minor
Found in source/javascripts/libs/swfobject-dynamic.js - About 3 days 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 242 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 source/javascripts/libs/swfobject-dynamic.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 source/javascripts/libs/swfobject-dynamic.js - About 2 hrs to fix

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

              embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, flashvarsObj, parObj, attObj, callbackFn) {
                  var callbackObj = {success:false, id:replaceElemIdStr};
                  if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
                    widthStr += ""; // auto-convert to string
                    heightStr += "";
      Severity: Minor
      Found in source/javascripts/libs/swfobject-dynamic.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 source/javascripts/libs/swfobject-dynamic.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) {
                        widthStr += ""; // auto-convert to string
                        heightStr += "";
                        var att = {};
                        if (attObj && typeof attObj === OBJECT) {
          Severity: Critical
          Found in source/javascripts/libs/swfobject-dynamic.js - About 1 hr to fix

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

                    embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, flashvarsObj, parObj, attObj, callbackFn) {
            Severity: Major
            Found in source/javascripts/libs/swfobject-dynamic.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 source/javascripts/libs/swfobject-dynamic.js - About 1 hr 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 source/javascripts/libs/swfobject-dynamic.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 source/javascripts/libs/swfobject-dynamic.js - About 45 mins to fix

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

                    var swfobject = function() {
                    
                        var UNDEF = "undefined",
                            OBJECT = "object",
                            SHOCKWAVE_FLASH = "Shockwave Flash",
                    Severity: Major
                    Found in source/javascripts/libs/swfobject-dynamic.js and 1 other location - About 2 wks to fix
                    .themes/classic/source/javascripts/libs/swfobject-dynamic.js on lines 5..298

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

                    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