CleverStack/clever-odm

View on GitHub
module.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function defineField has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  defineField: function(Klass, fields, mongooseConf, name) {
    var fieldDefinition = {}
      , columnName      = name
      , options         = Klass.fields[name];

Severity: Minor
Found in module.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 defineField has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  defineField: function(Klass, fields, mongooseConf, name) {
    var fieldDefinition = {}
      , columnName      = name
      , options         = Klass.fields[name];

Severity: Major
Found in module.js - About 2 hrs to fix

    Function getFieldType has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getFieldType: function(Klass, options, name) {
        var field;
    
        switch(options.type) {
    
    
    Severity: Minor
    Found in module.js - About 1 hr to fix

      Function parseModelSchema has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parseModelSchema: function(Klass, Proto) {
          var parseDebug = this.proxy(function(msg) {
                this.debug(Klass.modelName + 'Model: ' + msg);
              })
            , mongooseConf = {}
      Severity: Minor
      Found in module.js - About 1 hr to fix

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

          associateModels: function(Klass, Proto, assocType, assocTo) {
            var modelName   = Klass.modelName
              , models      = require('models');
        
            if (Klass.type.toLowerCase() === 'odm') {
        Severity: Minor
        Found in module.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 preSetup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          preSetup: function() {
            var dbConfig     = this.config.mongoose
              , queryLogger  = debug('cleverstack:queryLog');
        
            if (!!dbConfig.debug || queryLogger.enabled) {
        Severity: Minor
        Found in module.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

        There are no issues that match your filters.

        Category
        Status