kristok/node-pgq

View on GitHub

Showing 18 of 18 total issues

Function PgQDatabaseApi has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var PgQDatabaseApi = function(config) {
    var self = this;

    var initialize = function(dbConString) {
        self.db = db(dbConString);
Severity: Major
Found in lib/dbapi.js - About 5 hrs to fix

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

    module.exports = function(config) {
        var self = new EventEmitter();
    
        var initialize = function(config) {
            var requiredParams = {
    Severity: Major
    Found in lib/consumer.js - About 4 hrs to fix

      Function Ticker has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var Ticker = function(config) {
          var self = new EventEmitter(),
              sec = 100;
      
          var initialize = function(config) {
      Severity: Major
      Found in lib/ticker.js - About 3 hrs to fix

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

        module.exports = function(conString) {
            var self = {
                conString: conString
            };
        
        Severity: Minor
        Found in lib/db.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 Ticker has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        var Ticker = function(config) {
            var self = new EventEmitter(),
                sec = 100;
        
            var initialize = function(config) {
        Severity: Minor
        Found in lib/ticker.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

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

            var tickerLoop = function() {
                self.tick(function(err) {
                    self.ticker = setTimeout(tickerLoop, self.tickerPeriod);
                    if (err) {
                        self.emit('error', err);
        Severity: Major
        Found in lib/ticker.js and 1 other location - About 2 hrs to fix
        lib/ticker.js on lines 78..90

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

        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 retryLoop = function() {
                self.retry(function(err) {
                    self.retryTicker = setTimeout(
                        retryLoop,
                        self.retryPeriod
        Severity: Major
        Found in lib/ticker.js and 1 other location - About 2 hrs to fix
        lib/ticker.js on lines 31..40

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

        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

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

        module.exports = function(config) {
            var self = new EventEmitter();
        
            var initialize = function(config) {
                var requiredParams = {
        Severity: Minor
        Found in lib/consumer.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 exports has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(conString) {
            var self = {
                conString: conString
            };
        
        Severity: Minor
        Found in lib/db.js - About 1 hr to fix

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

          module.exports = function(api, setup, callback) {
              async.series([
          
                  function checkIfPgQSchemaExists(next) {
                      setup.emit('log', 'checking if pgq schema already exists');
          Severity: Minor
          Found in lib/installpgq.js - About 1 hr to fix

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

            EventBatch.prototype.tagRetryTimestamp = function(eventId, reinsertTimestamp, callback) {
                var self = this;
                this.tagRetry(
                    self.dbapi.eventTagRetryTimestamp,
                    eventId,
            Severity: Minor
            Found in lib/eventbatch.js and 1 other location - About 50 mins to fix
            lib/eventbatch.js on lines 47..55

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

            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

            EventBatch.prototype.tagRetrySeconds = function(eventId, delay, callback) {
                var self = this;
                this.tagRetry(
                    self.dbapi.eventTagRetrySeconds,
                    eventId,
            Severity: Minor
            Found in lib/eventbatch.js and 1 other location - About 50 mins to fix
            lib/eventbatch.js on lines 62..70

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

            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

            Consider simplifying this complex logical expression.
            Open

                    if (config && config.database) {
                        self.tickerPeriod = config.tickerPeriod || 1 * sec;
                        self.maintenancePeriod = config.maintenancePeriod || 120 * sec;
                        self.retryPeriod = config.retryPeriod || 30 * sec;
                        self.logDebug = config.logDebug || false;
            Severity: Major
            Found in lib/ticker.js - About 40 mins to fix

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

              module.exports = function(api, setup, callback) {
                  async.series([
              
                      function checkIfPgQSchemaExists(next) {
                          setup.emit('log', 'checking if pgq schema already exists');
              Severity: Minor
              Found in lib/installpgq.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

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

                  self.reinsertRetryEvents = function(callback) {
                      var query = 'SELECT * FROM pgq.maint_retry_events()';
                      self.db.query.first(query, [], callback);
                  };
              Severity: Minor
              Found in lib/dbapi.js and 2 other locations - About 35 mins to fix
              lib/dbapi.js on lines 156..159
              lib/dbapi.js on lines 165..168

              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

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

                  self.upgradeSchema = function(callback) {
                      var query = "SELECT * FROM pgq.upgrade_schema()";
                      self.db.query.first(query, [], callback);
                  };
              Severity: Minor
              Found in lib/dbapi.js and 2 other locations - About 35 mins to fix
              lib/dbapi.js on lines 151..154
              lib/dbapi.js on lines 156..159

              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

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

                  self.checkIfPgQSchemaExists = function(callback) {
                      var query = "SELECT true AS exists FROM pg_namespace WHERE nspname = 'pgq'";
                      self.db.query.first(query, [], callback);
                  };
              Severity: Minor
              Found in lib/dbapi.js and 2 other locations - About 35 mins to fix
              lib/dbapi.js on lines 151..154
              lib/dbapi.js on lines 165..168

              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

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

              var PgQDatabaseApi = function(config) {
                  var self = this;
              
                  var initialize = function(dbConString) {
                      self.db = db(dbConString);
              Severity: Minor
              Found in lib/dbapi.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