oglimmer/citybuilder

View on GitHub
server/rule_game.js

Summary

Maintainability
D
1 day
Test Coverage

File rule_game.js has 483 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Player = require("./rule_player.js");
var CardStack = require("./rule_cardstack.js");
var GameField = require('./rule_gamefield.js');
var Field = require('./rule_field.js');
var CardFactory = require('./rule_cardfactory.js');
Severity: Minor
Found in server/rule_game.js - About 7 hrs to fix

    Function removeCardFromAuction has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    Game.prototype.removeCardFromAuction = function(cardId, playerId) {
        var c = null;
        if(this.gameState == GameStates.PICK_CARD) {
            for(var i = 0 ; i < this.cardsToAuction.length ; i++) {
                if(this.cardsToAuction[i].id == cardId) {
    Severity: Minor
    Found in server/rule_game.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 processAuctionBid has 43 lines of code (exceeds 25 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 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 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

        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

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

          Game.prototype.resetSuppliesAndCalcBuildstate = function(changedFields) {
              for(var k in this.gameField.fields) {
                  var field = this.gameField.fields[k];            
                  if(field.buildState == 1) {
                      field.buildState++;
          Severity: Minor
          Found in server/rule_game.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

          There are no issues that match your filters.

          Category
          Status