rootslab/vapid

View on GitHub
lib/commands/pubsub.js

Summary

Maintainability
F
2 wks
Test Coverage

Function commands has a Cognitive Complexity of 196 (exceeds 5 allowed). Consider refactoring.
Open

exports.commands = function () {

    var keys = Object.keys
        , minimatch = require( 'minimatch' )
        , wmsg = function ( cmd ) {
Severity: Minor
Found in lib/commands/pubsub.js - About 4 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 commands has 343 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.commands = function () {

    var keys = Object.keys
        , minimatch = require( 'minimatch' )
        , wmsg = function ( cmd ) {
Severity: Major
Found in lib/commands/pubsub.js - About 1 day to fix

    File pubsub.js has 345 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * PUBSUB mix-ins.
     */
    
    exports.commands = function () {
    Severity: Minor
    Found in lib/commands/pubsub.js - About 4 hrs to fix

      Function unsubscribe has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              , unsubscribe : function ( command, args, sock ) {
                  var me = this
                      , channels = me.pubsub.channels
                      , alen = args.length
                      , a = 0
      Severity: Major
      Found in lib/commands/pubsub.js - About 2 hrs to fix

        Function punsubscribe has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                , punsubscribe : function ( command, args, sock ) {
                   var me = this
                        , patterns = me.pubsub.patterns
                        , alen = args.length
                        , a = 0
        Severity: Major
        Found in lib/commands/pubsub.js - About 2 hrs to fix

          Function psubscribe has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  , psubscribe : function ( command, args, sock ) {
                      var me = this
                          , patterns = me.pubsub.patterns
                          , spatterns = null
                          , alen = args.length
          Severity: Minor
          Found in lib/commands/pubsub.js - About 1 hr to fix

            Function channels has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        channels : function ( command, args, sock ) {
                            var me = this
                                , channels = me.pubsub.channels
                                , alen = args.length
                                , cmd = command[ 1 ]
            Severity: Minor
            Found in lib/commands/pubsub.js - About 1 hr to fix

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

                      , publish : function ( command, args, sock ) {
                          var me = this
                              , clients = me.clients
                              , pubsub = me.pubsub
                              , channels = pubsub.channels
              Severity: Minor
              Found in lib/commands/pubsub.js - About 1 hr to fix

                Function subscribe has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        , subscribe : function ( command, args, sock ) {
                            var me = this
                                , channels = me.pubsub.channels
                                , schannels = null
                                , alen = args.length
                Severity: Minor
                Found in lib/commands/pubsub.js - About 1 hr to fix

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

                              if ( ! alen ) {
                                  // no arguments, unsubscribe client from all channels
                                  for ( ; a < schannels.length; ++a ) {
                                      // NOTE: schannels length could change on every iteration
                                      cname = schannels[ a ];
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 1 day to fix
                  lib/commands/pubsub.js on lines 364..388

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

                  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 ( ! alen ) {
                                  // no arguments, unsubscribe client from all patterns
                                  for ( ; a < spatterns.length; ++a ) {
                                      // NOTE: spatterns length could change on every iteration
                                      pname = spatterns[ a ];
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 1 day to fix
                  lib/commands/pubsub.js on lines 283..307

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

                  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 ( ! ( spubsub && spubsub.channels.length ) ) {
                                  // client is not subscribed to any channel
                                  if ( ! alen ) return sock.write( ecmd + '$-1\r\n:0\r\n' );
                                  // send alen messages
                                  for ( ; a < alen; ++a ) {
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 5 hrs to fix
                  lib/commands/pubsub.js on lines 350..362

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

                  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 ( ! ( spubsub && spubsub.patterns.length ) ) {
                                  // client is not subscribed to any pattern
                                  if ( ! alen ) return sock.write( ecmd + '$-1\r\n:0\r\n' );
                                  // send alen messages
                                  for ( ; a < alen; ++a ) {
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 5 hrs to fix
                  lib/commands/pubsub.js on lines 269..281

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

                  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 me = this
                                  , patterns = me.pubsub.patterns
                                  , alen = args.length
                                  , a = 0
                                  , patt = null
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 4 hrs to fix
                  lib/commands/pubsub.js on lines 253..268

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

                  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 me = this
                                  , channels = me.pubsub.channels
                                  , alen = args.length
                                  , a = 0
                                  , chan = null
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 4 hrs to fix
                  lib/commands/pubsub.js on lines 334..349

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

                  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 me = this
                                  , patterns = me.pubsub.patterns
                                  , spatterns = null
                                  , alen = args.length
                                  , a = 0
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 3 hrs to fix
                  lib/commands/pubsub.js on lines 152..164

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

                  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 me = this
                                  , channels = me.pubsub.channels
                                  , schannels = null
                                  , alen = args.length
                                  , a = 0
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 3 hrs to fix
                  lib/commands/pubsub.js on lines 198..210

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

                  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 ( chan && chan.length ) {
                                      // check if subscriber already exists
                                      if ( ! ~ chan.indexOf( sock.name ) ) {
                                          chan.push( sock.name );
                                          schannels.push( cname );
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 1 hr to fix
                  lib/commands/pubsub.js on lines 222..241

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

                  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 ( patt && patt.length ) {
                                      // check if subscriber already exists
                                      if ( ! ~ patt.indexOf( sock.name ) ) {
                                          patt.push( sock.name );
                                          spatterns.push( pname );
                  Severity: Major
                  Found in lib/commands/pubsub.js and 1 other location - About 1 hr to fix
                  lib/commands/pubsub.js on lines 176..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 68.

                  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 ( chan && chan.length ) reply.push( '$' + byteLength( cname ) + crlf + cname + crlf ) & ++r;
                  Severity: Minor
                  Found in lib/commands/pubsub.js and 1 other location - About 40 mins to fix
                  lib/commands/pubsub.js on lines 47..47

                  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

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

                                          if ( chan && chan.length ) reply.push( '$' + byteLength( cname ) + crlf + cname + crlf ) & ++r;
                  Severity: Minor
                  Found in lib/commands/pubsub.js and 1 other location - About 40 mins to fix
                  lib/commands/pubsub.js on lines 62..62

                  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