oglimmer/citybuilder

View on GitHub

Showing 157 of 157 total issues

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

                for(var j = 0 ; j < this.currentHighlight.length ; j++) {
                    this.currentHighlight[j].fillStyleH = null;
                    this.currentHighlight[j].draw(G.ctx, this.relocateX, this.relocateY);
                }
Severity: Major
Found in client/game/FieldPane.js and 1 other location - About 1 hr to fix
client/game/FieldPane.js on lines 144..147

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

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

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

                  $("#gameCanvas").attr('width', $(window).width()-225).attr('height', $(window).height()-35);
          Severity: Major
          Found in client/game/GlobalListeners.js and 1 other location - About 1 hr to fix
          client/game/global_scope.js on lines 23..23

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

          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 4 locations. Consider refactoring.
          Open

                      logger.debug("[MorePopulationCard] Field "+field.x+","+field.y+" gained "+rand+" to now "+field.attachedCard.housePopulation);    
          Severity: Major
          Found in server/cards/card_other.js and 3 other locations - About 1 hr to fix
          server/cards/card_other.js on lines 43..43
          server/cards/card_other.js on lines 185..185
          server/rule_field.js on lines 57..57

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

          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

              $("#gameCanvas").attr('width', $(window).width()-225).attr('height', $(window).height()-35);
          Severity: Major
          Found in client/game/global_scope.js and 1 other location - About 1 hr to fix
          client/game/GlobalListeners.js on lines 70..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 55.

          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 4 locations. Consider refactoring.
          Open

                      logger.debug("[GentrificationCard] Changed houseType for " + field.x+","+field.y+" from "+oldHouseType+" to "+field.attachedCard.houseType);
          Severity: Major
          Found in server/cards/card_other.js and 3 other locations - About 1 hr to fix
          server/cards/card_other.js on lines 83..83
          server/cards/card_other.js on lines 185..185
          server/rule_field.js on lines 57..57

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

          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 4 locations. Consider refactoring.
          Open

                  logger.debug("[Field.socialChange] Changed houseType for " + field.x+","+field.y+" from "+oldHouseType+" to "+field.attachedCard.houseType);
          Severity: Major
          Found in server/rule_field.js and 3 other locations - About 1 hr to fix
          server/cards/card_other.js on lines 43..43
          server/cards/card_other.js on lines 83..83
          server/cards/card_other.js on lines 185..185

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

          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 4 locations. Consider refactoring.
          Open

                      logger.debug("[NewPeopleCard] Changed houseType for " + field.x+","+field.y+" from "+oldHouseType+" to "+field.attachedCard.houseType);
          Severity: Major
          Found in server/cards/card_other.js and 3 other locations - About 1 hr to fix
          server/cards/card_other.js on lines 43..43
          server/cards/card_other.js on lines 83..83
          server/rule_field.js on lines 57..57

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

          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

          function BuildJeweleryPreCard(id) {
              this.Inherits(BuildJeweleryCard,id,302,3,[ {ht:[1], pro:2000}, {ht:[2], pro:100} ], 15);
          }
          Severity: Minor
          Found in server/cards/card_jewelerycards.js and 1 other location - About 55 mins to fix
          server/cards/card_clothingcards.js on lines 83..85

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

          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

          function BuildClothingTeenPreCard(id) {
              this.Inherits(BuildClothingCard,id,208,4,[ {ht:[3], pro:250}, {ht:[4], pro:50} ], 5);
          }
          Severity: Minor
          Found in server/cards/card_clothingcards.js and 1 other location - About 55 mins to fix
          server/cards/card_jewelerycards.js on lines 35..37

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

          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 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
                Severity
                Category
                Status
                Source
                Language