fogine/couchbase-odm

View on GitHub

Showing 38 of 72 total issues

Function destroy has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Instance.prototype.destroy = Promise.method(function(options) {

    const self = this;
    options = options || {};

Severity: Minor
Found in lib/instance.js - About 1 hr to fix

    Function _touchTimestamps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    Instance.prototype._touchTimestamps = function(timestamps, options) {
        options = options || {};
    
        if (   !this.Model._dataHasObjectStructure()
                || (!this.Model.options.timestamps && !this.Model.options.paranoid)
    Severity: Minor
    Found in lib/instance.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 insert has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Instance.prototype.insert = Promise.method(function(options) {
    
        const self = this;
        let   report
            , timestampsBck;
    Severity: Minor
    Found in lib/instance.js - About 1 hr to fix

      Function CouchbaseODM has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function CouchbaseODM(options) {
      
          var defaults = {
              key: UUID4Key,
              refDocKey: RefDocKey,
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function _touchTimestamps has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Instance.prototype._touchTimestamps = function(timestamps, options) {
            options = options || {};
        
            if (   !this.Model._dataHasObjectStructure()
                    || (!this.Model.options.timestamps && !this.Model.options.paranoid)
        Severity: Minor
        Found in lib/instance.js - About 1 hr to fix

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

          Hook.runHooks = function(hookType) {
          
              if (   (typeof hookType === 'string' && !HookType.hasOwnProperty(hookType))
                  && HookValues.indexOf(hookType) === -1
                 ) {
          Severity: Minor
          Found in lib/hook.js - About 1 hr to fix

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

            Model.prototype.build = function(data, options) {
                const defaults = {
                    isNewRecord: true,
                    sanitize: false
                };
            Severity: Minor
            Found in lib/model.js - About 1 hr to fix

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

              function attachGetByRefDocMethods() {
                  const self = this;
                  const getByRefDocPrefix = 'getBy';
                  const refDocs = this.options.indexes.refDocs;
              
              
              Severity: Minor
              Found in lib/model.js - About 1 hr to fix

                Function validate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        validate: function(schema, data, parentSchema, dataPath, parentData, prop) {
                Severity: Minor
                Found in lib/validator.js - About 45 mins to fix

                  Function getByIdOrFail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Model.prototype.getByIdOrFail = Promise.method(function(id, options) {
                      let key = id;
                      const actions = [];
                      const defaults = {
                          paranoid: true,
                  Severity: Minor
                  Found in lib/model.js - About 45 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 (!_.isEmpty(_schema)) {
                                  _.set(out, ['items'], _schema);
                              }
                  Severity: Major
                  Found in lib/util/schema.js - About 45 mins to fix

                    Function validate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            validate: function(schema, data, parentSchema, dataPath, parentData, prop) {
                    Severity: Minor
                    Found in lib/validator.js - About 45 mins to fix

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

                      RefDocKey.prototype.generate = Promise.method(function(instance) {
                      
                          let id = "";
                          let instanceData = instance.getData();
                      
                      
                      Severity: Minor
                      Found in lib/key/refDocKey.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 _cloneData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Instance.prototype._cloneData = function(customizer) {
                          return _.cloneDeepWith(this.getData(), function(val) {
                              if (customizer instanceof Function) {
                                  let resolved = customizer(val);
                                  if (resolved !== undefined) {
                      Severity: Minor
                      Found in lib/instance.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

                      Avoid too many return statements within this function.
                      Open

                                      return Promise.reject(reason);
                      Severity: Major
                      Found in lib/instance.js - About 30 mins to fix

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

                        Hook.removeHook = function(hookType, name) {
                            if (HookValues.indexOf(HookType[hookType]) === -1) {
                                throw new HookError('Attempted to remove hook: ' + name + ' of invalid hook type.');
                            }
                        
                        
                        Severity: Minor
                        Found in lib/hook.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 Model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function Model(name, schema, options) {
                        
                            if (!name || (typeof name !== "string" && !(name instanceof String) )) {
                                throw new ModelError("Model's name must be non-empty string value");
                            }
                        Severity: Minor
                        Found in lib/model.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 build has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function build(options) {
                            const defaults = {
                                _data: true, //data json references
                                allErrors: false,
                                verbose: true, //include validated data in errors
                        Severity: Minor
                        Found in lib/validator.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