neotoma/sync-server

View on GitHub

Showing 278 of 278 total issues

Function getResource has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var getResource = (done) => {
    var mediaType = mime.lookup(url);
    mediaType = mediaType ? mediaType : 'application/json';

    request({
Severity: Minor
Found in app/controllers/item/getResource.js - About 1 hr to fix

    Function exports has 28 lines of code (exceeds 25 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 1 hr to fix

      Function exports has 28 lines of code (exceeds 25 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 1 hr to fix

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

          routeResources(app) {
            jsonapi.routeResource(app, 'get', '/sessions', undefined, function(req, res) {
              var data;
              var included = [];
              var userObject;
        Severity: Minor
        Found in app/routers/sessions.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 sendMail has a Cognitive Complexity of 10 (exceeds 5 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

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

        module.exports = function(object, document, name, type) {
          validateParams([{
            name: 'object', variable: object, required: true, requiredType: 'object'
          }, {
            name: 'document', variable: document, required: true, requiredType: 'object'
        Severity: Minor
        Found in app/lib/jsonapi/addRelationshipToResourceObject.js - About 1 hr to fix

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

          module.exports = function(objectName, object, propertyName, propertyValue) {
            var description = objectName + ' object has property ' + propertyName;
          
            if (propertyValue) {
              description += ' that matches ' + typeof propertyValue;
          Severity: Minor
          Found in app/lib/assertions/objectHasProperty.js - About 1 hr to fix

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

            module.exports = function(req, model, method, done) {
              validateParams([{
                name: 'req', variable: req, required: true
              }, {
                name: 'model', variable: model, required: true, requiredProperties: ['jsonapi']
            Severity: Minor
            Found in app/lib/jsonapi/modelQueryConditions.js - About 1 hr to fix

              Function validateResourceIdentifierObject has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        var validateResourceIdentifierObject = function(done) {
                          var errors = [];
              
                          if (!resourceObject.id) {
                            errors.push(new Error(`Relationship resource identifier object for "${relationshipName}" does not have id property`));
              Severity: Minor
              Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 1 hr to fix

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

                    validateParams([{
                      name: 'path', variable: path, required: true, requiredType: 'string'
                    }, {
                      name: 'userStorageAuth', variable: userStorageAuth, required: true, requiredProperties: ['storageToken']
                    }]);
                Severity: Minor
                Found in app/models/storage.js and 1 other location - About 55 mins to fix
                app/controllers/item/itemDataObjectsFromPage.js on lines 13..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 54.

                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

                  validateParams([{
                    name: 'page', variable: page, required: true, requiredType: 'object'
                  }, {
                    name: 'source', variable: source, required: true, requiredProperties: ['itemDataObjectsFromPagePathTemplate']
                  }]);
                Severity: Minor
                Found in app/controllers/item/itemDataObjectsFromPage.js and 1 other location - About 55 mins to fix
                app/models/storage.js on lines 74..78

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

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

                module.exports = function(page, pagination, contentType) {
                  validateParams([{
                    name: 'page', variable: page, required: true, requiredType: 'object'
                  }, {
                    name: 'contentType', variable: contentType, requiredProperties: ['pluralCamelName']
                Severity: Minor
                Found in app/controllers/item/itemsPageNextPagination.js - About 55 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

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

                module.exports = function(app) {
                  debug('start routeModelResources');
                
                  /**
                   * Negotiate the Content-Type and Accept request headers
                Severity: Minor
                Found in app/lib/jsonapi/routeModelResources.js - About 55 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

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

                module.exports = function(app, host) {
                  if (!host) {
                    return app.use(cors());
                  }
                
                
                Severity: Minor
                Found in app/routers/cors.js - About 55 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

                Function post has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      post: function(req, res, contactVerification, done) {
                        var authenticateUser = function(done) {
                          if (contactVerification.user && contactVerification.contactVerificationRequest.authenticateSession) {
                            req.logIn(contactVerification.user, function(error) {
                              if (!error) {
                Severity: Minor
                Found in app/models/contactVerification.js - About 55 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

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

                  var requireAdminAuthentication = (req, res, next) => {
                    if (middleware && middleware.requireAdminAuthentication) {
                      app.requireAdminAuthentication(req, res, next);
                    } else {
                      next();
                Severity: Minor
                Found in app/lib/jsonapi/routeResource.js and 1 other location - About 55 mins to fix
                app/lib/jsonapi/routeResource.js on lines 10..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 53.

                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

                  var requireAuthentication = (req, res, next) => {
                    if (middleware && middleware.requireAuthentication) {
                      app.requireAuthentication(req, res, next);
                    } else {
                      next();
                Severity: Minor
                Found in app/lib/jsonapi/routeResource.js and 1 other location - About 55 mins to fix
                app/lib/jsonapi/routeResource.js on lines 18..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 53.

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

                module.exports = function(user, source, storage, contentType, pagination, job, done) {
                Severity: Major
                Found in app/controllers/item/storeItemsPage.js - About 50 mins to fix

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

                      mockProperties: () => {
                        return { 
                          _id: ObjectId(),
                          event: 'notificationRequestEvent',
                          user: ObjectId(),
                  Severity: Minor
                  Found in fixtures/models.js and 1 other location - About 50 mins to fix
                  fixtures/models.js on lines 235..243

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

                  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

                      mockProperties: () => {
                        return { 
                          _id: ObjectId(),
                          name: 'storeAllItemsForUserStorageSource',
                          source: ObjectId(),
                  Severity: Minor
                  Found in fixtures/models.js and 1 other location - About 50 mins to fix
                  fixtures/models.js on lines 269..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 51.

                  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