lebretr/sequelize-oracle

View on GitHub
lib/dialects/mariadb/connector-manager.js

Summary

Maintainability
F
1 wk
Test Coverage

Function exports has 335 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (function() {
  var ConnectorManager = function(sequelize, config) {
    try {
      if (config.dialectModulePath) {
        mariadb = require(config.dialectModulePath)
Severity: Major
Found in lib/dialects/mariadb/connector-manager.js - About 1 day to fix

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

    module.exports = (function() {
      var ConnectorManager = function(sequelize, config) {
        try {
          if (config.dialectModulePath) {
            mariadb = require(config.dialectModulePath)
    Severity: Minor
    Found in lib/dialects/mariadb/connector-manager.js - About 1 day 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 ConnectorManager has 133 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var ConnectorManager = function(sequelize, config) {
        try {
          if (config.dialectModulePath) {
            mariadb = require(config.dialectModulePath)
          } else {
    Severity: Major
    Found in lib/dialects/mariadb/connector-manager.js - About 5 hrs to fix

      File connector-manager.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var mariadb
        , Pooling = require('generic-pool')
        , Query   = require("./query")
        , Utils   = require("../../utils")
        , without = function(arr, elem) { return arr.filter(function(e) { return e != elem }) }
      Severity: Minor
      Found in lib/dialects/mariadb/connector-manager.js - About 4 hrs to fix

        Function connect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var connect = function(done, config) {
            config = config || this.config
        
            var self = this
              , client
        Severity: Minor
        Found in lib/dialects/mariadb/connector-manager.js - About 1 hr to fix

          Function query has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            ConnectorManager.prototype.query = function(sql, callee, options) {
              if (!this.isConnected && !this.pool) {
                this.connect()
              }
          
          
          Severity: Minor
          Found in lib/dialects/mariadb/connector-manager.js - About 1 hr to fix

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

                if (this.useReplicaton) {
                  var reads = 0
                    , writes = 0
            
                  // Init configs with options from config if not present
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 1 other location - About 4 days to fix
            lib/dialects/oracle/connector-manager.js on lines 43..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 800.

            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

              ConnectorManager.prototype.__defineGetter__('hasQueuedItems', function() {
                return (this.queue.length > 0) || (this.activeQueue.length > 0) || (this.client && this.client._queue && (this.client._queue.length > 0))
              })
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 2 hrs to fix
            lib/dialects/mysql/connector-manager.js on lines 422..424
            lib/dialects/oracle/connector-manager.js on lines 444..446

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

            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

              var disconnectIfNoConnections = function() {
                var self = this
            
                this.disconnectTimeoutId && clearTimeout(this.disconnectTimeoutId)
                this.disconnectTimeoutId = setTimeout(function() {
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 2 hrs to fix
            lib/dialects/mysql/connector-manager.js on lines 435..442
            lib/dialects/oracle/connector-manager.js on lines 457..464

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

            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

                this.onProcessExit = function () {
                  //be nice & close our connections on exit
                  if (self.pool) {
                    self.pool.drain()
                  } else if (self.client) {
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 2 hrs to fix
            lib/dialects/mysql/connector-manager.js on lines 153..162
            lib/dialects/oracle/connector-manager.js on lines 149..158

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

            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

              var transferQueuedItems = function(count) {
                for(var i = 0; i < count; i++) {
                  var queueItem = this.queue.shift()
                  if (queueItem) {
                    enqueue.call(this, queueItem)
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 1 hr to fix
            lib/dialects/mysql/connector-manager.js on lines 383..390
            lib/dialects/oracle/connector-manager.js on lines 406..413

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

            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

                try {
                  if (config.dialectModulePath) {
                    mariadb = require(config.dialectModulePath)
                  } else {
                    mariadb = require('mariasql')
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 1 hr to fix
            lib/dialects/mysql/connector-manager.js on lines 9..17
            lib/dialects/oracle/connector-manager.js on lines 9..17

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

            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

              var dequeue = function(queueItem) {
                //return the item's connection to the pool
                if (this.pool) {
                  this.pool.release(queueItem.client)
                }
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 1 other location - About 1 hr to fix
            lib/dialects/oracle/connector-manager.js on lines 398..404

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

              var afterQuery = function(queueItem) {
                dequeue.call(this, queueItem)
                transferQueuedItems.call(this, this.maxConcurrentQueries - this.activeQueue.length)
                disconnectIfNoConnections.call(this)
              }
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 1 hr to fix
            lib/dialects/mysql/connector-manager.js on lines 392..396
            lib/dialects/oracle/connector-manager.js on lines 415..419

            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

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

              var handleDisconnect = function(pool, client) {
                client.on('error', function(err) {
                  if (err.code !== 'PROTOCOL_CONNECTION_LOST') {
                    throw err
                  }
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 1 hr to fix
            lib/dialects/mysql/connector-manager.js on lines 352..359
            lib/dialects/oracle/connector-manager.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 61.

            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

                if (config.dialectOptions) {
                  Object.keys(config.dialectOptions).forEach(function (key) {
                    connectionConfig[key] = config.dialectOptions[key];
                  })
                }
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 1 hr to fix
            lib/dialects/mysql/connector-manager.js on lines 307..311
            lib/dialects/oracle/connector-manager.js on lines 330..334

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

                queueItem.query
                  .success(function(){ afterQuery.call(self, queueItem) })
                  .error(function(){ afterQuery.call(self, queueItem) })
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 1 hr to fix
            lib/dialects/mysql/connector-manager.js on lines 414..416
            lib/dialects/oracle/connector-manager.js on lines 436..438

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

            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

              ConnectorManager.prototype.disconnect = function() {
                if (this.client) {
                  disconnect.call(this, this.client)
                }
                return
            Severity: Major
            Found in lib/dialects/mariadb/connector-manager.js and 2 other locations - About 45 mins to fix
            lib/dialects/mysql/connector-manager.js on lines 258..263
            lib/dialects/oracle/connector-manager.js on lines 254..259

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

            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