lebretr/sequelize-oracle

View on GitHub
lib/dialects/sqlite/query-generator.js

Summary

Maintainability
F
1 wk
Test Coverage

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

module.exports = (function() {
  var QueryGenerator = {
    options: {},
    dialect: 'sqlite',

Severity: Minor
Found in lib/dialects/sqlite/query-generator.js - About 2 days 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 335 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (function() {
  var QueryGenerator = {
    options: {},
    dialect: 'sqlite',

Severity: Major
Found in lib/dialects/sqlite/query-generator.js - About 1 day to fix

    File query-generator.js has 346 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var Utils       = require("../../utils")
      , DataTypes   = require("../../data-types")
      , SqlString   = require("../../sql-string")
      , Transaction = require("../../transaction")
    
    
    Severity: Minor
    Found in lib/dialects/sqlite/query-generator.js - About 4 hrs to fix

      Function createTableQuery has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          createTableQuery: function(tableName, attributes, options) {
            options = options || {}
      
            var query       = "CREATE TABLE IF NOT EXISTS <%= table %> (<%= attributes%>)"
              , primaryKeys = []
      Severity: Major
      Found in lib/dialects/sqlite/query-generator.js - About 2 hrs to fix

        Function attributesToSQL has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            attributesToSQL: function(attributes) {
              var result = {}
        
              for (var name in attributes) {
                var dataType = attributes[name]
        Severity: Major
        Found in lib/dialects/sqlite/query-generator.js - About 2 hrs to fix

          Avoid deeply nested control flow statements.
          Open

                        if (length.index < modifierLastIndex) {
                          modifierLastIndex -= length[0].length
                        }
          Severity: Major
          Found in lib/dialects/sqlite/query-generator.js - About 45 mins to fix

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

                bulkInsertQuery: function(tableName, attrValueHashes, options) {
                  var query = "INSERT<%= ignoreDuplicates %> INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
                    , tuples = []
                    , allAttributes = []
            
            
            Severity: Major
            Found in lib/dialects/sqlite/query-generator.js and 2 other locations - About 1 day to fix
            lib/dialects/mysql/query-generator.js on lines 181..210
            lib/dialects/oracle/query-generator.js on lines 160..189

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

            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(dataType.references) {
                        template += " REFERENCES <%= referencesTable %> (<%= referencesKey %>)"
                        replacements.referencesTable = this.quoteIdentifier(dataType.references)
            
                        if(dataType.referencesKey) {
            Severity: Major
            Found in lib/dialects/sqlite/query-generator.js and 1 other location - About 7 hrs to fix
            lib/dialects/postgres/query-generator.js on lines 477..496

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

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

                addLimitAndOffset: function(options, query){
                  query = query || ""
                  if (options.offset && !options.limit) {
                    query += " LIMIT " + options.offset + ", " + 10000000000000;
                  } else if (options.limit) {
            Severity: Major
            Found in lib/dialects/sqlite/query-generator.js and 2 other locations - About 5 hrs to fix
            lib/dialects/abstract/query-generator.js on lines 933..946
            lib/dialects/mysql/query-generator.js on lines 398..410

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

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

                quoteIdentifiers: function(identifiers, force) {
                  return identifiers.split('.').map(function(v) { return this.quoteIdentifier(v, force) }.bind(this)).join('.')
                },
            Severity: Major
            Found in lib/dialects/sqlite/query-generator.js and 3 other locations - About 1 hr to fix
            lib/dialects/mysql/query-generator.js on lines 417..419
            lib/dialects/oracle/query-generator.js on lines 379..381
            lib/dialects/postgres/query-generator.js on lines 817..819

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

            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

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

                dropTableQuery: function(tableName, options) {
                  options = options || {}
            
                  var query = "DROP TABLE IF EXISTS <%= table %>;"
            
            
            Severity: Major
            Found in lib/dialects/sqlite/query-generator.js and 1 other location - About 1 hr to fix
            lib/dialects/mysql/query-generator.js on lines 100..108

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

            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

                  for (var key in attrValueHash) {
                    var value = attrValueHash[key]
                    values.push(this.quoteIdentifier(key) + "=" + this.escape(value))
                  }
            Severity: Major
            Found in lib/dialects/sqlite/query-generator.js and 1 other location - About 1 hr to fix
            lib/dialects/abstract/query-generator.js on lines 263..266

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

            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

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

                      if (Utils.defaultValueSchemable(dataType.defaultValue)) {
                        // TODO thoroughly check that DataTypes.NOW will properly
                        // get populated on all databases as DEFAULT value
                        // i.e. mysql requires: DEFAULT CURRENT_TIMESTAMP
                        template += " DEFAULT <%= defaultValue %>"
            Severity: Minor
            Found in lib/dialects/sqlite/query-generator.js and 1 other location - About 55 mins to fix
            lib/dialects/postgres/query-generator.js on lines 461..467

            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 query = [
                    this.createTableQuery(backupTableName, attributes).replace('CREATE TABLE', 'CREATE TEMPORARY TABLE'),
                    "INSERT INTO <%= tableName %>_backup SELECT <%= attributeNamesImport %> FROM <%= tableName %>;",
                    "DROP TABLE <%= tableName %>;",
                    this.createTableQuery(tableName, attributes),
            Severity: Minor
            Found in lib/dialects/sqlite/query-generator.js and 1 other location - About 40 mins to fix
            lib/dialects/sqlite/query-generator.js on lines 356..363

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

                  var query = [
                    this.createTableQuery(backupTableName, attributes).replace('CREATE TABLE', 'CREATE TEMPORARY TABLE'),
                    "INSERT INTO <%= tableName %>_backup SELECT <%= attributeNames %> FROM <%= tableName %>;",
                    "DROP TABLE <%= tableName %>;",
                    this.createTableQuery(tableName, attributes),
            Severity: Minor
            Found in lib/dialects/sqlite/query-generator.js and 1 other location - About 40 mins to fix
            lib/dialects/sqlite/query-generator.js on lines 375..382

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

                  if (typeof indexName !== 'string') {
                    indexName = Utils._.underscored(tableName + '_' + indexNameOrAttributes.join('_'))
                  }
            Severity: Minor
            Found in lib/dialects/sqlite/query-generator.js and 2 other locations - About 40 mins to fix
            lib/dialects/mysql/query-generator.js on lines 301..303
            lib/dialects/postgres/query-generator.js on lines 401..403

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

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

                  var replacements = {
                    table: this.quoteIdentifier(tableName),
                    values: values.join(","),
                    where: this.getWhereConditions(where)
                  }
            Severity: Minor
            Found in lib/dialects/sqlite/query-generator.js and 2 other locations - About 35 mins to fix
            lib/dialects/abstract/query-generator.js on lines 194..198
            lib/dialects/abstract/query-generator.js on lines 268..272

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

            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

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

                  , pkString = primaryKeys.map(function(pk) { return this.quoteIdentifier(pk) }.bind(this)).join(", ")
            Severity: Minor
            Found in lib/dialects/sqlite/query-generator.js and 2 other locations - About 35 mins to fix
            lib/dialects/mysql/query-generator.js on lines 79..79
            lib/dialects/oracle/query-generator.js on lines 91..91

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

            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