peter/jsonapitest

View on GitHub

Showing 33 of 33 total issues

Function sortFunction has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

var sortFunction = function(value) {
  return function (a, b) {
    if (value.by) {
      a = a[value.by];
      b = b[value.by];
Severity: Minor
Found in lib/select_functions.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 request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

exports.request = function(options, callback) {
  var startTime = new Date().getTime(),
      headers = options.headers || {},
      method = options.method || 'GET',
      params = options.params || {},
Severity: Minor
Found in lib/http_clients/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 parseRequestString has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

var parseRequestString = function(apiCall) {
  if (typeof apiCall.request === 'string') {
    var parts = apiCall.request.split(' '),
        firstPart = parts[0],
        lastPart = parts[parts.length-1];
Severity: Minor
Found in lib/api_call.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 nestedValue has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var nestedValue = (function() {
  var assertValidArgs = function(hash, nestedKey) {
    if (hash == null || typeof hash !== 'object') {
      throw new UtilError('nested_value_invalid_hash', 'Expected object as hash argument but got ' + hash + " nestedKey=" + nestedKey);
    }
Severity: Minor
Found in lib/util.js - About 1 hr to fix

    Function equalValues has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    var equalValues = function(value1, value2) {
      if (value1 == null && value2 == null) {
        // both values are null/undefined
        return true;
      } else if (_.isRegExp(value2) && !_.isRegExp(value1)) {
    Severity: Minor
    Found in lib/util.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 request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.request = function(options, callback) {
      var startTime = new Date().getTime(),
          headers = options.headers || {},
          method = options.method || 'GET',
          params = options.params || {},
    Severity: Minor
    Found in lib/http_clients/request.js - About 1 hr to fix

      Function request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.request = function(options, callback) {
        var startTime = new Date().getTime(),
            options = options || {},
            method = clientMethod(options),
            url = options.url,
      Severity: Minor
      Found in lib/http_clients/superagent.js - About 1 hr to fix

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

            end: function(success, results) {
              var logPath = this.config.log_path;
              if (logPath) {
                output("\nlogging all results to " + logPath + "\n");
                if (!fs.existsSync(path.dirname(logPath))) fs.mkdirSync(path.dirname(logPath));
        Severity: Minor
        Found in lib/callbacks/console.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 request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.request = function(options, callback) {
          var startTime = new Date().getTime(),
              options = options || {},
              method = clientMethod(options),
              url = options.url,
        Severity: Minor
        Found in lib/http_clients/superagent.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 handleProperty has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var handleProperty = function(context, property, value) {
          switch(property) {
            case 'data':
              assertValidSchema(value, schema.data);
              context.data = util.deepMerge(context.data, value);
        Severity: Minor
        Found in lib/context_parser.js - About 1 hr to fix

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

            var paramsOptions = util.map(params, function(value, key) {
              return '-F "' + quote(key + '=' + value) + '"';
            }).join(' ');
          Severity: Minor
          Found in lib/callbacks/curl.js and 1 other location - About 55 mins to fix
          lib/callbacks/curl.js on lines 27..29

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

          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

            var fileOptions = util.map(files, function(value, key) {
              return '-F "' + quote(key + '=@' + value) + '"';
            }).join(' ');
          Severity: Minor
          Found in lib/callbacks/curl.js and 1 other location - About 55 mins to fix
          lib/callbacks/curl.js on lines 30..32

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

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

          module.exports = function(context) {
            var callbacks = util.array(util.loadModule(context, 'callbacks'));
            return {
              run: function(key, args, callback) {
                async.eachSeries(callbacks, function(callback, next) {
          Severity: Minor
          Found in lib/callbacks_helper.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 sort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.sort = function(value, response) {
            if (!util.isArray(response)) throw new util.Error('select_sort_non_array', 'Sort select function expected array but got ' + JSON.stringify(response));
            if (typeof value === 'string') {
              value = {order: value};
            } else {
          Severity: Minor
          Found in lib/select_functions.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

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

            if (options.files) {
              headers['Content-Type'] = 'multipart/form-data';
            } else if (!headers['Content-Type'] && method !== 'GET' && Object.keys(params).length > 0) {
              headers['Content-Type'] = 'application/json';    
            }
          Severity: Minor
          Found in lib/http_clients/superagent.js and 1 other location - About 55 mins to fix
          lib/http_clients/request.js on lines 22..26

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

          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

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

            if (options.files) {
              headers['Content-Type'] = 'multipart/form-data';
            } else if (!headers['Content-Type'] && method !== 'GET' && Object.keys(params).length > 0) {
              headers['Content-Type'] = 'application/json';    
            }
          Severity: Minor
          Found in lib/http_clients/request.js and 1 other location - About 55 mins to fix
          lib/http_clients/superagent.js on lines 21..25

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

          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

          Consider simplifying this complex logical expression.
          Open

              if (value1 && value2 && (_.isObject(value1) && !_.isArray(value1)) && (_.isObject(value2) && !_.isArray(value2))) {
                  result[key] = deepMerge(value1, value2);
              } else {
                result[key] = (value2 === undefined ? value1 : value2);
                if (result[key] && _.isObject(result[key])) result[key] = _.cloneDeep(result[key]);
          Severity: Major
          Found in lib/util.js - About 40 mins to fix

            Function run has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            exports.run = function(context, suite, test, apiCallRaw, callback) {
            Severity: Minor
            Found in lib/api_call.js - About 35 mins to fix

              Function end has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  end: function(suite, test, apiCall, err, result) {
              Severity: Minor
              Found in lib/callbacks/console.js - About 35 mins to fix

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

                  if (apiCall.headers && apiCall.request) {
                    apiCall.request.headers = apiCall.headers;
                    delete apiCall.headers;
                  }
                Severity: Minor
                Found in lib/api_call.js and 1 other location - About 35 mins to fix
                lib/api_call.js on lines 43..46

                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

                Severity
                Category
                Status
                Source
                Language