holidayextras/jsonapi-client

View on GitHub

Showing 21 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

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

            assert.deepEqual(person.photos[0].toJSON(), {
              "id": "72695cbd-e9ef-44f6-85e0-0dbc06a269e8",
              "type": "photos",
              "height": 220,
              "title": "Penguins",
    Severity: Major
    Found in test/read.js and 1 other location - About 2 hrs to fix
    test/read.js on lines 146..163

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

    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

            assert.deepEqual(person.photos[0].toJSON(), {
              "id": "72695cbd-e9ef-44f6-85e0-0dbc06a269e8",
              "type": "photos",
              "height": 220,
              "title": "Penguins",
    Severity: Major
    Found in test/read.js and 1 other location - About 2 hrs to fix
    test/read.js on lines 260..277

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

    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

              async.waterfall([
                function(cb) {
                  res.article.sync(function() { cb(); });
                },
                function(cb) {
    Severity: Major
    Found in test/write.js and 1 other location - About 2 hrs to fix
    test/write.js on lines 115..126

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

    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

              async.waterfall([
                function(cb) {
                  res.article.sync(function() { cb(); });
                },
                function(cb) {
    Severity: Major
    Found in test/write.js and 1 other location - About 2 hrs to fix
    test/write.js on lines 133..144

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

    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

    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

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

          xit("is denied access with the blockMe cookie", function(done) {
            var client = new Client("http://localhost:16006/rest", {
              cookie: {
                blockMe: true
              }
      Severity: Major
      Found in test/authentication.js and 1 other location - About 2 hrs to fix
      test/authentication.js on lines 9..20

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

      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

          it("is denied access with the blockme header", function(done) {
            var client = new Client("http://localhost:16006/rest", {
              header: {
                blockme: true
              }
      Severity: Major
      Found in test/authentication.js and 1 other location - About 2 hrs to fix
      test/authentication.js on lines 22..33

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

      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 _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

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

                  async.apply(async.parallel, {
                    article: function(callback) {
                      client.get("articles", "1be0913c-3c25-4261-98f1-e41174025ed5", callback);
                    },
                    tag: function(callback) {
          Severity: Major
          Found in test/write.js and 1 other location - About 1 hr to fix
          test/write.js on lines 156..163

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

          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

                  async.apply(async.parallel, {
                    article: function(callback) {
                      client.get("articles", "1be0913c-3c25-4261-98f1-e41174025ed5", callback);
                    },
                    tag: function(callback) {
          Severity: Major
          Found in test/write.js and 1 other location - About 1 hr to fix
          test/write.js on lines 105..112

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

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

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

                  var url = this._path + "/" + resource._getBase().type + "/" + resource._getBase().id;
                Severity: Minor
                Found in lib/Transport.js and 1 other location - About 40 mins to fix
                lib/Transport.js on lines 133..133

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

                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

                  var url = this._path + "/" + resource._getBase().type + "/" + resource._getBase().id;
                Severity: Minor
                Found in lib/Transport.js and 1 other location - About 40 mins to fix
                lib/Transport.js on lines 126..126

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

                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 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(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