oglimmer/citybuilder

View on GitHub

Showing 82 of 157 total issues

Function draw has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.draw = function(ctx) {  
        if(this.visible) {
            ctx.beginPath();
            ctx.rect(this.x,this.y,this.width,this.height);
            ctx.fillStyle = '#8ED6FF';
Severity: Minor
Found in client/game/InfoField.js - About 1 hr to fix

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

    module.exports = function(player) {
        var socket = player.getSocket();
        this.emit = function(name, msg) {
            socket.emit(name, msg);
        };
    Severity: Minor
    Found in server/socket.js - About 1 hr to fix

      Function draw has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          this.draw = function(ctx) {  
              ctx.font = '12px Arial';    
              ctx.beginPath();
              ctx.rect(this.x,this.y,this.width,this.height);
              if(this.clicked) {
      Severity: Minor
      Found in client/game/Card.js - About 1 hr to fix

        Function onclick has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        CanvasManagerUIMode.prototype.onclick = function(x,y) {
            if(this.enabled) {
                for(var i = this.elements.length - 1 ; i>= 0 ; i--) {
                    var ele = this.elements[i][2];
                    if(typeof(ele.onclick) === 'function' && ele.onclick(x,y)) {
        Severity: Minor
        Found in client/game/CanvasManager.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 AuctionCard has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function AuctionCard(id,title,text,x,y,profitConfig,range,localLevelMod,type,ctx) {
            this.Inherits(BaseCard);
            this.id = id;
            this.title = title;
            this.text = text;
        Severity: Minor
        Found in client/game/Card.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 onTurnDone has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            this.onTurnDone = function() {
                this.showWaitOverlay();
                G.turnDoneButton.enabled = false;        
                if(G.gameState == 1) {
                    socket.emit('roundEnd_req', { playerId : G.playerId});
        Severity: Minor
        Found in client/game/ServerCommListener.js - About 1 hr to fix

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

              this.moveover = function(x,y) {
                  if(!this.selectTargetEnabled) {
                      return;
                  }
                  for(var i = 0 ; i < this.allElements.length ; i++) {
          Severity: Minor
          Found in client/game/FieldPane.js - About 1 hr to fix

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

            Game.removePlayer = function(socketId, onSuccess, onGameDeleted) {
                var PlayerManager = require('./rule_playermanager.js');
                var GameManager = require('./rule_gamemanager.js');
                PlayerManager.getPlayerBySocketId(socketId, function(player) {
                    GameManager.getGame(player.gameId, function(game) {
            Severity: Minor
            Found in server/rule_game.js - About 1 hr to fix

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

              Player.prototype.playCard = function(cardIdToPlay,targetFieldId,onSuccess,onFail) {
                  // check if player is able to deploy a card this turn
                  if(this.availableActions & 1 == 0) {
                      logger.debug("[playCard] availableActions="+this.availableActions+", return from playCard");
                      return;
              Severity: Minor
              Found in server/rule_player.js - About 1 hr to fix

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

                    this.calcRanges = function(type) {    
                        for(var i = 0 ; i < this.allElements.length ; i++) {
                            var field = this.allElements[i];
                            if(field.type == 0 ) {
                                field.influenced = 0;
                Severity: Minor
                Found in client/game/FieldPane.js - About 1 hr to fix

                  Function processAuctionBid has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Game.prototype.processAuctionBid = function(allPlayers) {
                      logger.debug("[processAuctionBid] start. this.biddings=%j", this.biddings);
                  
                      this.gameState = GameStates.PICK_CARD;
                      // if a player had left the game and rejoined again his bidding is undefined. So tread this as $0.
                  Severity: Minor
                  Found in server/rule_game.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

                  Function storePlayer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      storePlayer : function(player, prepare, onSuccess) {
                          if(prepare!=null) {
                              prepare(player);
                          }
                          db.insert(player, function(err, body) {
                  Severity: Minor
                  Found in server/rule_playermanager.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

                  Function calcLocalLevel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  RentalCard.prototype.calcLocalLevel = function(field, fields, changedFields) {    
                      Card.forEachField(this.range, field, fields, function(surroundingElement) {
                          if(surroundingElement.type == FieldType.HOUSE) {
                              if(typeof this.changeLocalLevel !== 'undefined') {
                                  if(this.changeLocalLevel(surroundingElement)) {
                  Severity: Minor
                  Found in server/cards/card_basecards.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

                  Function draw has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  UIElement.prototype.draw = function(ctx, relocateX, relocateY) {
                      ctx.beginPath();
                      
                      // get the background-color
                      if(this.fillStyleH != null) {
                  Severity: Minor
                  Found in client/game/UIElement.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

                  Avoid deeply nested control flow statements.
                  Open

                                      for(var j = pf.ht[0] ; j <= pf.ht[1] ; j++) {
                                          if(j!==pf.ht[0]) {
                                              text += " / ";
                                          }
                                          text += UIServices.getHouseTypeText(j);
                  Severity: Major
                  Found in client/game/Card.js - About 45 mins to fix

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

                    BaseCard.drawText = function(ctx,text,profitConfig,x,y,width) {
                    Severity: Minor
                    Found in client/game/Card.js - About 45 mins to fix

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

                      function RentalCard(id,no,range,type,profitConfig,localLevelMod) {
                      Severity: Minor
                      Found in server/cards/card_basecards.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            for(var k = start ; k <= end ; k++) {
                                                if(k!==start) {
                                                    tempTxtDisp += " / ";
                                                }
                                                tempTxtDisp += UIServices.getHouseTypeText(k);
                        Severity: Major
                        Found in client/game/Card.js - About 45 mins to fix

                          Function getButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          CanvasManager.prototype.getButton = function(x,y) {
                              if(this.enabled) {
                                  for(var i = this.elements.length - 1 ; i>= 0 ; i--) {
                                      var ele = this.elements[i][2];
                                      if(typeof(ele.atPos) === 'function' && ele.atPos(x,y)) {
                          Severity: Minor
                          Found in client/game/CanvasManager.js - About 45 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

                          Avoid deeply nested control flow statements.
                          Open

                                              if(this.cardsToAuction[j].cardsToSelect[i].id == cardId) {
                                                  c = this.cardsToAuction[j].cardsToSelect[i];
                                              }
                          Severity: Major
                          Found in server/rule_game.js - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language