cozy/cozy-mobile

View on GitHub

Showing 8 of 8 total issues

Function request has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

function request(options, callback) {
  // The entry-point to the API: prep the options object and pass the real work to run_xhr.
  if(typeof callback !== 'function')
    throw new Error('Bad callback given: ' + callback)

Severity: Minor
Found in src/app/lib/request.js - About 7 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 request has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function request(options, callback) {
  // The entry-point to the API: prep the options object and pass the real work to run_xhr.
  if(typeof callback !== 'function')
    throw new Error('Bad callback given: ' + callback)

Severity: Major
Found in src/app/lib/request.js - About 4 hrs to fix

    Function run_xhr has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function run_xhr(options) {
      var xhr = new XHR
        , timed_out = false
        , is_cors = is_crossDomain(options.uri)
        , supports_cors = ('withCredentials' in xhr)
    Severity: Minor
    Found in src/app/lib/request.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 run_xhr has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function run_xhr(options) {
      var xhr = new XHR
        , timed_out = false
        , is_cors = is_crossDomain(options.uri)
        , supports_cors = ('withCredentials' in xhr)
    Severity: Major
    Found in src/app/lib/request.js - About 3 hrs to fix

      File request.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // Browser Request
      //
      // Licensed under the Apache License, Version 2.0 (the "License");
      // you may not use this file except in compliance with the License.
      // You may obtain a copy of the License at
      Severity: Minor
      Found in src/app/lib/request.js - About 3 hrs to fix

        Function couch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        request.couch = function(options, callback) {
          if(typeof options === 'string')
            options = {'uri':options}
        
          // Just use the request API to do JSON.
        Severity: Minor
        Found in src/app/lib/request.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 defaults has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        request.defaults = function(options, requester) {
          var def = function (method) {
            var d = function (params, callback) {
              if(typeof params === 'string')
                params = {'uri': params};
        Severity: Minor
        Found in src/app/lib/request.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 is_crossDomain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function is_crossDomain(url) {
          var rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/
        
          // jQuery #8138, IE may throw an exception when accessing
          // a field from window.location if document.domain has been set
        Severity: Minor
        Found in src/app/lib/request.js - About 25 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