holidayextras/jsonapi-client

View on GitHub
lib/Resource.js

Summary

Maintainability
B
5 hrs
Test Coverage

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

    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

        There are no issues that match your filters.

        Category
        Status