TJRoger/node-dota2-spectator

View on GitHub

Showing 26 of 26 total issues

Function analyze has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

exports.analyze = function(tokens) {
  var root = new exports.Node();
  
  while (tokens.length > 0) {
    var cur = tokens.shift();
Severity: Minor
Found in resources/steam_language_parser/parser/token_analyzer.js - About 5 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 parseInnerScope has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

function parseInnerScope(tokens, parent, root) {
  var scope1 = expect(tokens, 'operator', '{');
  var scope2 = optional(tokens, 'operator', '}');
  
  while (!scope2) {
Severity: Minor
Found in resources/steam_language_parser/parser/token_analyzer.js - About 3 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 analyze has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.analyze = function(tokens) {
  var root = new exports.Node();
  
  while (tokens.length > 0) {
    var cur = tokens.shift();
Severity: Major
Found in resources/steam_language_parser/parser/token_analyzer.js - About 2 hrs to fix

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

    exports.lookupSymbol = function(tree, identifier, strongonly) {
      var ident = identifierRegex.exec(identifier);
      
      if (!ident) {
        throw new Error("Invalid identifier specified " + identifier);
    Severity: Minor
    Found in resources/steam_language_parser/parser/symbol_locator.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 parseInnerScope has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function parseInnerScope(tokens, parent, root) {
      var scope1 = expect(tokens, 'operator', '{');
      var scope2 = optional(tokens, 'operator', '}');
      
      while (!scope2) {
    Severity: Minor
    Found in resources/steam_language_parser/parser/token_analyzer.js - About 1 hr to fix

      Function Dota2Client has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var Dota2Client = function Dota2Client(user, gc, debug) {
          EventEmitter.call(this);
      
          this.debug = debug;
          this._client = user._client;
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function emitClassEncoder has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function emitClassEncoder(cnode, baseSize) {
          Steam.Internal[cnode.name].prototype.encode = function() {
            // first emit variable length members
            var varLengthProps = [];
            
        Severity: Minor
        Found in resources/steam_language_parser/generator/node_gen.js - About 1 hr to fix

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

            Steam.Internal[cnode.name].prototype.encode = function() {
              // first emit variable length members
              var varLengthProps = [];
              
              cnode.childNodes.forEach(function(prop) {
          Severity: Minor
          Found in resources/steam_language_parser/generator/node_gen.js - About 1 hr to fix

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

            function emitClassConstructor(cnode) {
              Steam.Internal[cnode.name] = function(object) {
                object = object || {};
                
                cnode.childNodes.forEach(function(prop) {
            Severity: Minor
            Found in resources/steam_language_parser/generator/node_gen.js - About 1 hr to fix

              Function getTypeSize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.getTypeSize = function(prop) {
                var sym = prop.type;
                
                // no static size for proto
                if (prop.flags == 'proto') {
              Severity: Minor
              Found in resources/steam_language_parser/code_generator.js - About 1 hr 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 emitClassDecoder has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function emitClassDecoder(cnode) {
                Steam.Internal[cnode.name].decode = function(buffer) {
                  if (!ByteBuffer.isByteBuffer(buffer)) {
                    buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
                  }
              Severity: Minor
              Found in resources/steam_language_parser/generator/node_gen.js - About 1 hr to fix

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

                  Steam.Internal[cnode.name].decode = function(buffer) {
                    if (!ByteBuffer.isByteBuffer(buffer)) {
                      buffer = ByteBuffer.wrap(buffer, ByteBuffer.LITTLE_ENDIAN);
                    }
                    
                Severity: Minor
                Found in resources/steam_language_parser/generator/node_gen.js - About 1 hr to fix

                  Function lookupSymbol has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.lookupSymbol = function(tree, identifier, strongonly) {
                    var ident = identifierRegex.exec(identifier);
                    
                    if (!ident) {
                      throw new Error("Invalid identifier specified " + identifier);
                  Severity: Minor
                  Found in resources/steam_language_parser/parser/symbol_locator.js - About 1 hr to fix

                    Function Dota2Client has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    var Dota2Client = function Dota2Client(user, gc, debug) {
                        EventEmitter.call(this);
                    
                        this.debug = debug;
                        this._client = user._client;
                    Severity: Minor
                    Found in index.js - About 1 hr 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 tokenizeString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.tokenizeString = function(buffer) {
                      var match;
                    
                      var tokenList = [];
                      while ((match = regexPattern.exec(buffer))) {
                    Severity: Minor
                    Found in resources/steam_language_parser/parser/language_parser.js - About 1 hr 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 gcClientConnectionStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    handlers[Dota2.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus] = function gcClientConnectionStatus(message) {
                      /* Catch and handle changes in connection status, cuz reasons u know. */
                    
                      var status = Dota2.CMsgConnectionStatus.decode(message).status;
                      util.log(util.inspect(message, false, null));
                    Severity: Minor
                    Found in index.js - About 1 hr 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 getTypeOfSize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.getTypeOfSize = function(size, unsigned) {
                      for (var key in weakTypeMap) {
                        if (weakTypeMap[key].size == size) {
                          if (unsigned && !weakTypeMap[key].signed)
                            return key;
                    Severity: Minor
                    Found in resources/steam_language_parser/code_generator.js - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

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

                        this._gc.send({
                            msg:  Dota2.EDOTAGCMsg.k_EMsgGCFindSourceTVGames,
                            proto: {}
                        },
                        new Dota2.CMsgFindSourceTVGames(filterOptions).toBuffer(),
                    Severity: Minor
                    Found in handlers/sourcetv.js and 1 other location - About 50 mins to fix
                    handlers/sourcetv.js on lines 52..56

                    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

                        this._gc.send({
                            msg: Dota2.EDOTAGCMsg.k_EMsgGCSpectateFriendGame,
                            proto: {}
                        },new Dota2.CMsgSpectateFriendGame(friend).toBuffer(),
                        callback);
                    Severity: Minor
                    Found in handlers/sourcetv.js and 1 other location - About 50 mins to fix
                    handlers/sourcetv.js on lines 33..38

                    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

                    Function emitCode has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    exports.emitCode = function(root, gen, sb, nspace, supportsGC, internalFile) {
                    Severity: Minor
                    Found in resources/steam_language_parser/code_generator.js - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language