neotoma/sync-server

View on GitHub

Showing 278 of 278 total issues

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

  }, {
    when: 'provided page with meta containing client error code',
    params: [wh.itemPage(wh.one('source'), wh.one('contentType'), wh.one('userSourceAuth'), {
      meta: {
        code: 450
Severity: Major
Found in tests/controllers/item/itemsPageError.js and 2 other locations - About 3 hrs to fix
tests/controllers/item/itemsPageError.js on lines 36..47
tests/controllers/item/itemsPageError.js on lines 58..69

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

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

module.exports = function(user, storage, path, data, done) {
  var log = logger.scopedLog();

  var validate = (done) => {
    validateParams([{
Severity: Major
Found in app/controllers/item/storeFile.js - About 3 hrs to fix

    Function registerTask has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var registerTask = function(grunt) {
      /**
       * Remove database collections and seed them with resourceObjects stored in files
       * @param {string} [args] – rsync arguments
       */
    Severity: Major
    Found in app/lib/tasks/grunt-data-seed.js - About 3 hrs to fix

      Function new has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        new: function(name, properties, statics, methods, schemaMods) {
          // Add default definition to properties with references and load reference schemas
          Object.keys(properties).forEach(function(key) {
            var modifiedProperty = (property) => {
              if (property.ref) {
      Severity: Minor
      Found in app/factories/model.js - About 3 hrs 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 saveRelationshipsToDocument has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var saveRelationshipsToDocument = function(done) {
          // eslint-disable-next-line global-require
          var Model = require(`app/models/${document.modelId()}`);
          
          async.forEachOf(relationships, function(relationship, relationshipName, done) {
      Severity: Major
      Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 2 hrs to fix

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

        module.exports = function(user, source, storage, contentType, done) {
          var saveUser = (done) => {
            user.save((error) => {
              debug('saved user %s', user.id);
              done(error);
        Severity: Major
        Found in tests/controllers/item/routines/prepareStoreAll.js - About 2 hrs to fix

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

          module.exports = function(grunt) {
            'use strict';
          
            grunt.initConfig({
              clean: {
          Severity: Major
          Found in Gruntfile.js - About 2 hrs to fix

            Function new has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              new: function(name, properties, statics, methods, schemaMods) {
                // Add default definition to properties with references and load reference schemas
                Object.keys(properties).forEach(function(key) {
                  var modifiedProperty = (property) => {
                    if (property.ref) {
            Severity: Major
            Found in app/factories/model.js - About 2 hrs to fix

              Function routeResources has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                routeResources(app) {
                  jsonapi.routeResource(app, 'get', '/sessions', undefined, function(req, res) {
                    var data;
                    var included = [];
                    var userObject;
              Severity: Major
              Found in app/routers/sessions.js - About 2 hrs to fix

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

                  }, {
                    when: 'item parameter has no user property',
                    params: [wh.one('item'), wh.jsonData(), wh.one('job')],
                    error: 'Parameter item has no user property',
                    before: function(done) {
                Severity: Major
                Found in tests/controllers/item/storeItemData.js and 1 other location - About 2 hrs to fix
                tests/controllers/item/storeItemData.js on lines 37..48

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

                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

                  }, {
                    when: 'item parameter has no storage property',
                    params: [wh.one('item'), wh.jsonData(), wh.one('job')],
                    error: 'Parameter item has no storage property',
                    before: function(done) {
                Severity: Major
                Found in tests/controllers/item/storeItemData.js and 1 other location - About 2 hrs to fix
                tests/controllers/item/storeItemData.js on lines 26..37

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

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

                module.exports = function(objectName, object, properties) {
                  it(objectName + ' object toObject method returns properties', (done) => {
                    var returnedObject = object.toObject();
                
                    for (var property in properties) {
                Severity: Minor
                Found in app/lib/assertions/objectToObjectMethodReturnsProperties.js - About 2 hrs 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

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

                      assert.equal(itemsGetUrl, templateCompiler('https://${host}/${contentTypePluralCamelName}?access_token=${accessToken}&limit=${limit}&offset=${offset}', {
                        host: this.params[0].host,
                        contentTypePluralCamelName: this.params[1].pluralCamelName(),
                        accessToken: this.params[2].sourceToken,
                        limit: this.params[0].itemsLimit,
                Severity: Major
                Found in tests/controllers/item/itemsGetUrl.js and 1 other location - About 2 hrs to fix
                tests/controllers/item/itemsGetUrl.js on lines 15..21

                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

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

                      assert.equal(itemsGetUrl, templateCompiler(this.params[0].itemsGetUrlTemplate, {
                        host: this.params[0].host,
                        contentTypePluralCamelName: this.params[1].pluralCamelName(),
                        accessToken: this.params[2].sourceToken,
                        limit: this.params[0].itemsLimit,
                Severity: Major
                Found in tests/controllers/item/itemsGetUrl.js and 1 other location - About 2 hrs to fix
                tests/controllers/item/itemsGetUrl.js on lines 28..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 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

                Function exports has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function(model) {
                  return (req, res, next) => {
                    var errors = [];
                
                    debug('req.body %o', req.body);
                Severity: Minor
                Found in app/lib/jsonapi/validateRequestBody.js - About 2 hrs 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 exports has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function(app, Model) {
                  routeModelResource(app, Model, 'post', '/'+ _.kebabCase(Model.modelType()), (req, res) => {
                    /**
                     * Validates all available attributes (TODO: and relationships)
                     */
                Severity: Major
                Found in app/lib/jsonapi/routeModelPostObjectResource.js - About 2 hrs to fix

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

                  module.exports = function(url, done) {
                    var log = logger.scopedLog();
                  
                    var validate = (done) => {
                      validateParams([{
                  Severity: Major
                  Found in app/controllers/item/getResource.js - About 2 hrs to fix

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

                    module.exports = function(document) {
                      if (!document) {
                        throw new Error('No document provided');
                      }
                    
                    
                    Severity: Major
                    Found in app/lib/jsonapi/resourceObjectFromDocument.js - About 2 hrs to fix

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

                      module.exports = function(app, Model) {
                        routeModelResource(app, Model, 'patch', '/' + _.kebabCase(Model.modelType()) + '/:id', (req, res) => {
                          var validate = (done) => {
                            validateQueryData(req, req.body.data, Model, 'patch', done);
                          };
                      Severity: Major
                      Found in app/lib/jsonapi/routeModelPatchObjectResource.js - About 2 hrs to fix

                        Function exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = function(modelId) {
                          var fixture = modelFixtures[modelId];
                        
                          if (!fixture) {
                            throw new Error(`Unable to load fixture for ${modelId}`);
                        Severity: Minor
                        Found in app/lib/factory.js - About 2 hrs 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

                        Severity
                        Category
                        Status
                        Source
                        Language