Showing 11 of 21 total issues
File Resource.js
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/* @flow weak */
"use strict";
var Resource = module.exports = function(rawResource, client) {
rawResource = rawResource || { };
return this._construct(rawResource, client);
File read.js
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"use strict";
var assert = require("assert");
var Client = require("../.");
require("./_testServer.js");
Function _action
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function exports
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function(config) {
config.set({
sauceLabs: {
testName: "jsonapi-client full stack tests"
},
Function createResourceCache
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function createResourceCache(options) {
options = options || { };
var resourceCache = {};
resourceCache._cacheDuration = options.cacheDuration || 5000;
Function _associateWith
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Resource.prototype._associateWith = function(resource) {
var self = this;
var relationships = self._getRaw().relationships;
if (!relationships) return;
Object.keys(relationships).forEach(function(relationName) {
Function relationships
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Resource.prototype.relationships = function(relationName) {
var self = this;
var rawRelation = this._raw.relationships[relationName];
if (!self._base.id) {
Function toJSONTree
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
Resource.prototype.toJSONTree = function(seen) {
seen = seen || [ ];
if (seen.indexOf(this) !== -1) return "[Circular]";
seen.push(this);
var theirs = this._raw;
- Read upRead up
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
Open
return callback(null, payload.body, payload.body.data, payload.body.included);
Avoid too many return
statements within this function. Open
Open
return callback(Transport._defaultError(payload));
Avoid too many return
statements within this function. Open
Open
return callback(Transport._defaultError(payload));