holidayextras/jsonapi-client

View on GitHub

Showing 11 of 21 total issues

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

/* @flow weak */
"use strict";
var Resource = module.exports = function(rawResource, client) {
  rawResource = rawResource || { };
  return this._construct(rawResource, client);
Severity: Minor
Found in lib/Resource.js - About 3 hrs to fix

    File read.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    "use strict";
    var assert = require("assert");
    var Client = require("../.");
    require("./_testServer.js");
    
    
    Severity: Minor
    Found in test/read.js - About 2 hrs to fix

      Function _action has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Transport.prototype._action = function(method, url, data, callback) {
        // console.log(method, url, JSON.stringify(data, null, 2));
        var someRequest = request[method](url);
        someRequest.set("Content-Type", "application/vnd.api+json");
        this._attachAuthToRequest(someRequest);
      Severity: Minor
      Found in lib/Transport.js - About 1 hr to fix

        Function exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(config) {
          config.set({
            sauceLabs: {
              testName: "jsonapi-client full stack tests"
            },
        Severity: Minor
        Found in karma.saucelabs.conf.js - About 1 hr to fix

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

          module.exports = function createResourceCache(options) {
            options = options || { };
            var resourceCache = {};
          
            resourceCache._cacheDuration = options.cacheDuration || 5000;
          Severity: Minor
          Found in lib/resourceCache.js - About 1 hr to fix

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

            Resource.prototype._associateWith = function(resource) {
              var self = this;
              var relationships = self._getRaw().relationships;
              if (!relationships) return;
              Object.keys(relationships).forEach(function(relationName) {
            Severity: Minor
            Found in lib/Resource.js - About 1 hr to fix

              Function relationships has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Resource.prototype.relationships = function(relationName) {
                var self = this;
                var rawRelation = this._raw.relationships[relationName];
              
                if (!self._base.id) {
              Severity: Minor
              Found in lib/Resource.js - About 1 hr to fix

                Function toJSONTree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                Resource.prototype.toJSONTree = function(seen) {
                  seen = seen || [ ];
                  if (seen.indexOf(this) !== -1) return "[Circular]";
                  seen.push(this);
                  var theirs = this._raw;
                Severity: Minor
                Found in lib/Resource.js - About 35 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

                Avoid too many return statements within this function.
                Open

                    return callback(null, payload.body, payload.body.data, payload.body.included);
                Severity: Major
                Found in lib/Transport.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return callback(Transport._defaultError(payload));
                  Severity: Major
                  Found in lib/Transport.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return callback(Transport._defaultError(payload));
                    Severity: Major
                    Found in lib/Transport.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language