CleverStack/clever-orm

View on GitHub
module.js

Summary

Maintainability
F
3 days
Test Coverage

File module.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var injector   = require('injector')
  , Sequelize  = require('sequelize')
  , debug      = require('debug')
  , utils      = require('utils')
  , Module     = injector.getInstance('Module')
Severity: Minor
Found in module.js - About 2 hrs to fix

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

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

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

        defineField: function(Static, fields, name) {
          var fieldDefinition = {}
            , columnName      = name
            , options         = Static.fields[name];
      
      
      Severity: Minor
      Found in module.js - About 1 hr to fix

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

          setupOptions: function(parseDebug, sequelizeConf, Static) {
            parseDebug('Setup options...');
        
            if (Static.dbName !== false ) {
              parseDebug('Setting dbName=' + Static.dbName + ' (sequelize tableName option)...');
        Severity: Minor
        Found in module.js - About 1 hr to fix

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

            defineField: function(Static, fields, name) {
              var fieldDefinition = {}
                , columnName      = name
                , options         = Static.fields[name];
          
          
          Severity: Minor
          Found in module.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

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

            setupOptions: function(parseDebug, sequelizeConf, Static) {
              parseDebug('Setup options...');
          
              if (Static.dbName !== false ) {
                parseDebug('Setting dbName=' + Static.dbName + ' (sequelize tableName option)...');
          Severity: Minor
          Found in module.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

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

            getFieldType: function(Static, options, name) {
              var field;
          
              switch(options.type.type || options.type) {
          
          
          Severity: Minor
          Found in module.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

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

            bigIntType: function(options) {
              var field = !!options.length ? Sequelize.BIGINT(options.length) : Sequelize.BIGINT;
              if (!!options.unsigned && !!options.zerofill) {
                field = field.UNSIGNED.ZEROFILL;
              } else if (!!options.unsigned && !options.zerofill) {
          Severity: Major
          Found in module.js and 1 other location - About 6 hrs to fix
          module.js on lines 285..295

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

          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

            numberType: function(options) {
              var field = !!options.length ? Sequelize.INTEGER(options.length) : Sequelize.INTEGER;
              if (!!options.unsigned && !!options.zerofill) {
                field = field.UNSIGNED.ZEROFILL;
              } else if (!!options.unsigned && !options.zerofill) {
          Severity: Major
          Found in module.js and 1 other location - About 6 hrs to fix
          module.js on lines 309..319

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

          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

              if (!!options.scale) {
                field = Sequelize.DECIMAL(options.precision, options.scale);
              } else if (!!options.precision) {
                field = Sequelize.DECIMAL(options.precision);
              }
          Severity: Major
          Found in module.js and 1 other location - About 1 hr to fix
          module.js on lines 323..327

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

          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

              if (!!options.decimals) {
                field = Sequelize.FLOAT(options.length, options.decimals);
              } else if (!!options.length) {
                field = Sequelize.FLOAT(options.length);
              }
          Severity: Major
          Found in module.js and 1 other location - About 1 hr to fix
          module.js on lines 341..345

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

          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 6 locations. Consider refactoring.
          Open

              if (Static.charset !== false ) {
                parseDebug('Setting charset=' + Static.charset + '...');
                sequelizeConf.charset = Static.charset;
              }
          Severity: Major
          Found in module.js and 5 other locations - About 40 mins to fix
          module.js on lines 114..117
          module.js on lines 119..122
          module.js on lines 129..132
          module.js on lines 139..142
          module.js on lines 144..147

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

          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 6 locations. Consider refactoring.
          Open

              if (Static.collate !== false ) {
                parseDebug('Setting collate=' + Static.collate + '...');
                sequelizeConf.collate = Static.collate;
              }
          Severity: Major
          Found in module.js and 5 other locations - About 40 mins to fix
          module.js on lines 114..117
          module.js on lines 119..122
          module.js on lines 129..132
          module.js on lines 134..137
          module.js on lines 139..142

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

          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 6 locations. Consider refactoring.
          Open

              if (Static.freezeDbName !== false) {
                parseDebug('Setting freezeDbName=' + Static.freezeDbName + ' (sequelize freezeTableName option)...');
                sequelizeConf.freezeTableName = Static.freezeDbName;
              }
          Severity: Major
          Found in module.js and 5 other locations - About 40 mins to fix
          module.js on lines 114..117
          module.js on lines 129..132
          module.js on lines 134..137
          module.js on lines 139..142
          module.js on lines 144..147

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

          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 6 locations. Consider refactoring.
          Open

              if (Static.engine !== false) {
                parseDebug('Setting engine=' + Static.engine + '...');
                sequelizeConf.engine = Static.engine;
              }
          Severity: Major
          Found in module.js and 5 other locations - About 40 mins to fix
          module.js on lines 114..117
          module.js on lines 119..122
          module.js on lines 134..137
          module.js on lines 139..142
          module.js on lines 144..147

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

          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 6 locations. Consider refactoring.
          Open

              if (Static.dbName !== false ) {
                parseDebug('Setting dbName=' + Static.dbName + ' (sequelize tableName option)...');
                sequelizeConf.tableName = Static.dbName;
              }
          Severity: Major
          Found in module.js and 5 other locations - About 40 mins to fix
          module.js on lines 119..122
          module.js on lines 129..132
          module.js on lines 134..137
          module.js on lines 139..142
          module.js on lines 144..147

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

          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 6 locations. Consider refactoring.
          Open

              if (Static.comment !== false ) {
                parseDebug('Setting comment=' + Static.comment + '...');
                sequelizeConf.comment = Static.comment;
              }
          Severity: Major
          Found in module.js and 5 other locations - About 40 mins to fix
          module.js on lines 114..117
          module.js on lines 119..122
          module.js on lines 129..132
          module.js on lines 134..137
          module.js on lines 144..147

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

          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

          There are no issues that match your filters.

          Category
          Status