neotoma/sync-server

View on GitHub

Showing 278 of 278 total issues

Function formatData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var formatData = (id, done) => {
    var formattedData = {
      'id': id,
      'type': item.contentType.pluralLowercaseName(),
      'attributes': {}
Severity: Minor
Found in app/controllers/item/storeItemData.js - About 1 hr to fix

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

    module.exports = function(modelFixture, properties) {
      return (done) => {
        if (modelFixture.schemaProperties) {
          debug('creating populated properties %O', properties);
    
    
    Severity: Minor
    Found in app/lib/createPopulatedProperties.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

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

    }, {
      jsonapi: {
        get: {
          allowed: 'user',
          queryConditions: queryConditions.userMatchesRequester
    Severity: Major
    Found in app/models/notificationRequest.js and 1 other location - About 1 hr to fix
    app/models/job.js on lines 39..54

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

    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

    }, {
      jsonapi: {
        get: {
          allowed: 'user',
          queryConditions: queryConditions.userMatchesRequester
    Severity: Major
    Found in app/models/job.js and 1 other location - About 1 hr to fix
    app/models/notificationRequest.js on lines 24..39

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

    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 13 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function(user, source, storage, contentType, job, done) {
      var log = logger.scopedLog();
    
      var validate = (done) => {
        validateParams([{
    Severity: Minor
    Found in app/controllers/item/storeAllForUserStorageSourceContentType.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 post has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          post: function(req, res, contactVerificationRequest, done) {
            var generateCodeAndSave = (done) => {
              crypto.randomBytes(32, (error, buffer) => {
                if (error) {
                  return done(new Error(`Failed to generate code: ${error.message}`));
    Severity: Minor
    Found in app/models/contactVerificationRequest.js - About 1 hr to fix

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

      module.exports = function(Model, method, tests) {
        tests.forEach((test) => {
          var description = _.toUpper(method) + ' requests to ' + Model.modelName;
          var Test = supertest(app)[method]('/' + _.kebabCase(Model.modelType()));
      
      
      Severity: Minor
      Found in app/lib/assertions/route.js - About 1 hr to fix

        Function runTest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var runTest = function(test, done) {
            try {
              if (test.required && !test.variable) {
                throw new Error('Parameter ' + test.name + ' undefined or null');
              }
        Severity: Minor
        Found in app/lib/validateParams.js - About 1 hr to fix

          Function validateAndAddResourceIdentifierObjectRelationship has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  var validateAndAddResourceIdentifierObjectRelationship = function(resourceObject, done) {
                    var validateResourceIdentifierObject = function(done) {
                      var errors = [];
          
                      if (!resourceObject.id) {
          Severity: Minor
          Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 1 hr to fix

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

            module.exports = function(name) {
              // Ensure env variable is loaded even if debug module was previously loaded with other value
              Debug.enable(process.env.DEBUG);
            
              var debug = Debug(name);
            Severity: Minor
            Found in app/lib/debug.js - About 1 hr to fix

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

                }, {
                  when: 'provided url without authorization',
                  params: [wh.jsonUrl],
                  error: 'Failed to make successful request. HTTP status code: 401',
                  before: function(done) {
              Severity: Major
              Found in tests/controllers/item/getResource.js and 1 other location - About 1 hr to fix
              tests/controllers/item/getResource.js on lines 29..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 64.

              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: 'url parameter indicates non-existent resource',
                  params: [wh.jsonUrl],
                  error: 'Failed to make successful request. HTTP status code: 404',
                  before: function(done) {
              Severity: Major
              Found in tests/controllers/item/getResource.js and 1 other location - About 1 hr to fix
              tests/controllers/item/getResource.js on lines 37..45

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

              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 12 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function(app, method, path, middleware, done) {
                var requireAuthentication = (req, res, next) => {
                  if (middleware && middleware.requireAuthentication) {
                    app.requireAuthentication(req, res, next);
                  } else {
              Severity: Minor
              Found in app/lib/jsonapi/routeResource.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 authsRouter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var authsRouter = function(app) {
                app.get('/:type/:id/auth', reqPassportDocument, function(req, res, next) {
                  if (!req.document) {
                    return res.sendStatus(404);
                  }
              Severity: Minor
              Found in app/routers/auths.js - About 1 hr to fix

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

                module.exports = function(user, source, storage, job, done) {
                  var log = logger.scopedLog();
                
                  var validate = (done) => {
                    validateParams([{
                Severity: Minor
                Found in app/controllers/item/storeAllForUserStorageSource.js - About 1 hr to fix

                  Function sendMail has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  mailer.sendMail = function(email, done) {
                    try {
                      var senderEmail = process.env.SYNC_SERVER_MAILER_SENDER_EMAIL;
                      var serverName = process.env.SYNC_SERVER_NAME ? process.env.SYNC_SERVER_NAME : 'Neotoma';
                  
                  
                  Severity: Minor
                  Found in app/lib/mailer.js - About 1 hr to fix

                    Function exports has a Cognitive Complexity of 11 (exceeds 5 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: Minor
                    Found in app/lib/jsonapi/routeModelPostObjectResource.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

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

                      totalItemsAvailableFromPagePath: function(contentType) {
                        return templateCompiler(this.totalItemsAvailableFromPagePathTemplate, {
                          contentTypePluralCamelName: contentType ? contentType.pluralCamelName() : undefined,
                          contentTypePluralLowercaseName: contentType ? contentType.pluralLowercaseName() : undefined
                        });
                    Severity: Major
                    Found in app/models/source.js and 1 other location - About 1 hr to fix
                    app/models/source.js on lines 12..17

                    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 exports has a Cognitive Complexity of 11 (exceeds 5 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: Minor
                    Found in app/lib/jsonapi/routeModelPatchObjectResource.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

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

                      itemDataObjectsFromPagePath: function(contentType) {
                        return templateCompiler(this.itemDataObjectsFromPagePathTemplate, {
                          contentTypePluralCamelName: contentType ? contentType.pluralCamelName() : undefined,
                          contentTypePluralLowercaseName: contentType ? contentType.pluralLowercaseName() : undefined
                        });
                    Severity: Major
                    Found in app/models/source.js and 1 other location - About 1 hr to fix
                    app/models/source.js on lines 19..24

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language