endpoints/endpoints

View on GitHub

Showing 109 of 109 total issues

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

  return _lodash2['default'].transform(obj, function (result, n, key) {
    var val = String(n);
    result[key] = val.indexOf(',') === -1 ? val : val.split(',');
  });
Severity: Major
Found in es5/request-handler/lib/split_string_props.js and 1 other location - About 1 hr to fix
src/request-handler/lib/split_string_props.js on lines 4..7

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

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

  return _lodash2['default'].chain(sortBy).filter(function (key) {
    var hasSortDir = key[0] === ' ' || key[0] === '+' || key[0] === '-';
    var isValidField = _lodash2['default'].contains(validFields, key.substring(1));
    return hasSortDir && isValidField;
  }).reduce(function (result, key) {
Severity: Major
Found in es5/store-bookshelf/lib/read.js and 1 other location - About 1 hr to fix
src/store-bookshelf/lib/read.js on lines 68..76

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

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

  return _.chain(sortBy).filter(function (key) {
    var hasSortDir = key[0] === ' ' || key[0] === '+' || key[0] === '-';
    var isValidField = _.contains(validFields, key.substring(1));
    return hasSortDir && isValidField;
  }).reduce(function (result, key) {
Severity: Major
Found in src/store-bookshelf/lib/read.js and 1 other location - About 1 hr to fix
es5/store-bookshelf/lib/read.js on lines 89..97

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

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

  create (config, data) {
    return {
      code: '201',
      data: this.formatter.process(data, {
        singleResult: true
Severity: Major
Found in src/payload-handler/index.js and 1 other location - About 1 hr to fix
es5/payload-handler/index.js on lines 24..34

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

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

  PayloadHandler.prototype.create = function create(config, data) {
    return {
      code: '201',
      data: this.formatter.process(data, {
        singleResult: true
Severity: Major
Found in es5/payload-handler/index.js and 1 other location - About 1 hr to fix
src/payload-handler/index.js on lines 10..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 60.

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

export default function (file, searchPaths) {
  if (!searchPaths) {
    throw new Error('No searchPaths specified.');
  }
  var result = null;
Severity: Minor
Found in src/application/lib/require_search.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 validate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  validate (request) {

    var err;
    var validators = [];

Severity: Minor
Found in src/request-handler/index.js - About 1 hr to fix

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

    function destructure(model) {
      var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
    
      var relationships = params.relationships || {};
      var relationshipNames = _lodash2['default'].keys(relationships);
    Severity: Minor
    Found in es5/store-bookshelf/lib/destructure.js - About 1 hr to fix

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

        PayloadHandler.prototype.error = function error(errs, defaultErr) {
          var resp;
      
          defaultErr = defaultErr || 400;
          errs = errs || [_kapow2['default'](defaultErr)];
      Severity: Minor
      Found in es5/payload-handler/index.js - About 1 hr to fix

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

          error (errs, defaultErr) {
            var resp;
        
            defaultErr = defaultErr || 400;
            errs = errs || [Kapow(defaultErr)];
        Severity: Minor
        Found in src/payload-handler/index.js - About 1 hr to fix

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

            JsonApiFormat.prototype.process = function process(input) {
              var _this = this;
          
              var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
              var singleResult = opts.singleResult;
          Severity: Minor
          Found in es5/format-jsonapi/index.js - About 1 hr to fix

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

            exports["default"] = function (model, relationName) {
              var src = model.forge ? model : model.constructor;
              return src.forge().related(relationName).relatedData.target.collection();
            };
            Severity: Major
            Found in es5/store-bookshelf/lib/related_collection.js and 1 other location - About 1 hr to fix
            src/store-bookshelf/lib/related_collection.js on lines 8..11

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

            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

            export default function (model, relationName) {
              const src = model.forge ? model : model.constructor;
              return src.forge().related(relationName).relatedData.target.collection();
            }
            Severity: Major
            Found in src/store-bookshelf/lib/related_collection.js and 1 other location - About 1 hr to fix
            es5/store-bookshelf/lib/related_collection.js on lines 12..15

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

            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 destructure has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function destructure (model, params={}) {
              const relationships = params.relationships || {};
              const relationshipNames = _.keys(relationships);
              const allRels = allRelations(model);
              const toOneRelsMap = toOneRelations(model);
            Severity: Minor
            Found in src/store-bookshelf/lib/destructure.js - About 1 hr to fix

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

                validate (request) {
              
                  var err;
                  var validators = [];
              
              
              Severity: Minor
              Found in src/request-handler/index.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 default has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function (file, searchPaths) {
                if (!searchPaths) {
                  throw new Error('No searchPaths specified.');
                }
                var result = null;
              Severity: Minor
              Found in src/application/lib/require_search.js - About 1 hr to fix

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

                function read(model) {
                  var query = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
                  var mode = arguments.length <= 2 || arguments[2] === undefined ? 'read' : arguments[2];
                
                  return _columns2['default'](model).then(function (modelColumns) {
                Severity: Minor
                Found in es5/store-bookshelf/lib/read.js - About 1 hr to fix

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

                  export default function type (model) {
                    return model.constructor.typeName ||
                      model.typeName ||
                      model.prototype && model.prototype.tableName ||
                      model.tableName;
                  Severity: Major
                  Found in src/store-bookshelf/lib/type.js and 1 other location - About 1 hr to fix
                  es5/store-bookshelf/lib/type.js on lines 14..16

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

                  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

                  function type(model) {
                    return model.constructor.typeName || model.typeName || model.prototype && model.prototype.tableName || model.tableName;
                  }
                  Severity: Major
                  Found in es5/store-bookshelf/lib/type.js and 1 other location - About 1 hr to fix
                  src/store-bookshelf/lib/type.js on lines 9..14

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

                  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 format has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    JsonApiFormat.prototype.format = function format(model) {
                      var includedRelations = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
                      var mode = arguments.length <= 2 || arguments[2] === undefined ? 'read' : arguments[2];
                  
                      var store = this.store;
                  Severity: Minor
                  Found in es5/format-jsonapi/index.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language