yoctore/yocto-mongoose

View on GitHub

Showing 32 of 82 total issues

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

Enums.prototype.load = function (path) {
  try {
    // test is a valid path
    if (!_.isString(path) || _.isEmpty(path)) {
      throw 'Invalid path given.';
Severity: Minor
Found in src/modules/enum/index.js - About 1 hr to fix

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

    YMongoose.prototype.disconnect = function () {
      // Create our deferred object, which we will use in our promise chain
      var deferred = Q.defer();
    
      // try to disconnect
    Severity: Minor
    Found in src/index.js - About 1 hr to fix

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

      RedisUtils.prototype.listenEvents = function () {
        // default events
        var events = [
          { key : 'connect', message      : 'is connecting' },
          { key : 'ready', message        : 'is ready' },
      Severity: Minor
      Found in src/modules/utils/redis.js - About 1 hr to fix

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

        Crud.prototype.create = function (value) {
          // Create our deferred object, which we will use in our promise chain
          var deferred = Q.defer();
          // create default instance model
          var model = !_.isFunction(this.save) ? new this() : this;
        Severity: Minor
        Found in src/modules/crud/index.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

        Avoid deeply nested control flow statements.
        Open

                      if (err) {
                        // reject with error message
                        deferred.reject([ '[ Crud.create ] - Indexes creation failed :', err ].join(' '));
                      } else {
                        // resolve default statement
        Severity: Major
        Found in src/modules/crud/index.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        if (item.redis) {
                          // has custom redis expire time define on schema for specific key/method ?
                          if (!_.isArray(schema.redisExpireTimeByKey)) {
                            // create default item
                            schema.redisExpireTimeByKey = [];
          Severity: Major
          Found in src/modules/method/index.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if ((item.type === 'post' || item.type === 'pre') &&
                            _.isString(item.event) && !_.isEmpty(item.event)) {
                            // debug message
                            this.logger.debug([ '[ Method.add ] - Adding [', item.type,
                              ' ] hook on current schema for event [', item.event, ']' ].join(' '));
            Severity: Major
            Found in src/modules/method/index.js - About 45 mins to fix

              Function add has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              Method.prototype.add = function (schema, path, items, modelName, redis) {
              Severity: Minor
              Found in src/modules/method/index.js - About 35 mins to fix

                Function add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                Crud.prototype.add = function (schema, exclude, redisIncludes, redis) {
                  // valid data ?
                  if ((!_.isObject(schema) && !(schema instanceof Schema)) || !_.isArray(exclude)) {
                    this.logger.warning('[ Crud.add ] - Schema or exclude item given is invalid');
                    // invalid statement
                Severity: Minor
                Found in src/modules/crud/index.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

                Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                Enums.prototype.get = function (name) {
                  // is a valid string ?
                  if (_.isString(name) && !_.isEmpty(name)) {
                    // data is ok so try to get enums from given name
                    if (_.isArray(this.enums) && !_.isEmpty(this.enums)) {
                Severity: Minor
                Found in src/modules/enum/index.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

                Function load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                YMongoose.prototype.load = function () {
                  // Create our deferred object, which we will use in our promise chain
                  var deferred = Q.defer();
                
                  var errors  = [];   // list of errors
                Severity: Minor
                Found in src/index.js - About 25 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 addDefaultIndexes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                ElasticUtils.prototype.addDefaultIndexes = function (obj) {
                  // first test
                  if (!obj || !_.isObject(obj)) {
                    // default statement
                    return obj;
                Severity: Minor
                Found in src/modules/utils/elastic.js - About 25 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

                Severity
                Category
                Status
                Source
                Language