conversant/ad-libs.js

View on GitHub

Showing 84 of 84 total issues

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

var createScript = function (url, loaded, requestTimeout, target) {
    var script = d.createElement('script'),
        timeoutId;

    if (!target){
Severity: Minor
Found in lib/loadScript.js - About 1 hr to fix

    Function loadScript has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    var loadScript = function (urls, onLoaded, onError, requestTimeout, target) {
        var queue = 0,
            errorUrls = [],
            url,
            i;
    Severity: Minor
    Found in lib/loadScript.js - About 1 hr 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 getExecutingScript has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    var getExecutingScript = function (validatorFunc, testScript) {
        var currentScriptEl = testScript || document.currentScript, // FF 4+, Chrome 29+, Opera 16+, Safari 7+
            outputScriptEl = null,
            scripts,
            scriptEl,
    Severity: Minor
    Found in lib/dom/getExecutingScript.js - About 1 hr 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 getAppleOS has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    var getAppleOS = function (win, ua) {
    
        var mac = /Mac/i,
            iOS = /iPhone|iPad|iPod/i,
            appleBrowser = new Browser(),
    Severity: Minor
    Found in lib/detect/browser.js - About 1 hr 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 formatUrl has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var formatUrl = function (components) {
        var protocol = components.protocol || '',
            host = components.host,
            pathname = components.pathname || '',
            search = components.search || '',
    Severity: Minor
    Found in lib/url/format.js - About 1 hr to fix

      Function getSafariVersion has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var getSafariVersion = function (win, uaVersion) {
      
          var safariVersion = DEFAULT_VERSION,
              d = win.document,
              nav = win.navigator;
      Severity: Minor
      Found in lib/detect/browser.js - About 1 hr to fix

        Function xhr has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var xhr = function (options, callback) {
            var method = options.method || 'GET',
                withCredentials = options.withCredentials || false,
                url = options.url,
                responseType = options.responseType || 'text',
        Severity: Minor
        Found in lib/xhr.js - About 1 hr to fix

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

          var getAppleOS = function (win, ua) {
          
              var mac = /Mac/i,
                  iOS = /iPhone|iPad|iPod/i,
                  appleBrowser = new Browser(),
          Severity: Minor
          Found in lib/detect/browser.js - About 1 hr to fix

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

                self.getTimeline = function () {
                    var timelineMap = [],
                        time,
                        calculatedStart;
            
            
            Severity: Minor
            Found in lib/performanceMarker.js - About 1 hr to fix

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

                  environment.avail_h = Math.max((can(doc, 'documentElement') && has('clientWidth', doc.documentElement)) || 0, has('outerWidth') || 0).toFixed(0);
              Severity: Major
              Found in lib/detect/environment.js and 2 other locations - About 1 hr to fix
              lib/detect/environment.js on lines 226..226
              lib/detect/environment.js on lines 227..227

              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 3 locations. Consider refactoring.
              Open

                  environment.ad_w = Math.max((can(doc, 'documentElement') && has('clientWidth', doc.documentElement)) || 0, has('innerWidth') || 0).toFixed(0);
              Severity: Major
              Found in lib/detect/environment.js and 2 other locations - About 1 hr to fix
              lib/detect/environment.js on lines 223..223
              lib/detect/environment.js on lines 227..227

              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 3 locations. Consider refactoring.
              Open

                  environment.ad_h = Math.max((can(doc, 'documentElement') && has('clientHeight', doc.documentElement)) || 0, has('innerHeight') || 0).toFixed(0);
              Severity: Major
              Found in lib/detect/environment.js and 2 other locations - About 1 hr to fix
              lib/detect/environment.js on lines 223..223
              lib/detect/environment.js on lines 226..226

              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

              Function getTridentVersion has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              var getTridentVersion = function (win, uaVersion) {
              
                  var tridentVersion = DEFAULT_VERSION,
                      d = win.document;
                  // Detect all IE versions possible by feature detection
              Severity: Minor
              Found in lib/detect/browser.js - About 1 hr 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 createScript has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              var createScript = function (url, loaded, requestTimeout, target) {
                  var script = d.createElement('script'),
                      timeoutId;
              
                  if (!target){
              Severity: Minor
              Found in lib/loadScript.js - About 1 hr 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 getConf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              var    getConf = function (win) {
                      win = win || window;
                      var conf = [],
                          len = CONF_FIELDS.length,
                          i;
              Severity: Minor
              Found in lib/detect/safeframe.js - About 1 hr 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 2 locations. Consider refactoring.
              Open

                  if (has('wiiu', win)) {
                      otherBrowser.os.name = 'Wii';
                      otherBrowser.os.version = 'U';
                      otherBrowser.name = 'NetFront';
                      otherBrowser.console = true;
              Severity: Major
              Found in lib/detect/browser.js and 1 other location - About 1 hr to fix
              lib/detect/browser.js on lines 704..724

              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 (looksLike(/PlayStation.4/i, ua)) {
                      otherBrowser.os.name = 'PlayStation';
                      otherBrowser.os.version = '4';
                      otherBrowser.name = 'NetFront';
                      otherBrowser.console = true;
              Severity: Major
              Found in lib/detect/browser.js and 1 other location - About 1 hr to fix
              lib/detect/browser.js on lines 695..724

              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 getOtherOS has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              var getOtherOS = function (win, ua) {
              
                  var otherBrowser = new Browser();
              
                  if (has('wiiu', win)) {
              Severity: Minor
              Found in lib/detect/browser.js - About 55 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 getFlashVersion has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              var getFlashVersion = function () {
                  if (can(nav, 'plugins') && !has('ActiveXObject')) { // standards compliant browsers
              
                      return checkPlugin('Shockwave Flash'); //Flash version
              
              
              Severity: Minor
              Found in lib/detect/environment.js - About 55 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 detect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              var detect = function (win) {
                  win = win || window;
              
                  var document = win.document,
                      top = win.top,
              Severity: Minor
              Found in lib/detect/capabilities.js - About 45 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