oglimmer/citybuilder

View on GitHub

Showing 157 of 157 total issues

Function FieldPane has a Cognitive Complexity of 131 (exceeds 5 allowed). Consider refactoring.
Open

function FieldPane() {

    this.relocateX = 0;  
    this.relocateY = 0;
    this.allElements = [];
Severity: Minor
Found in client/game/FieldPane.js - About 2 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 ServerCommListener has 251 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ServerCommListener() {    
    var time = null;
    this.showWaitOverlay = function() {
        $('#overlay').show();
        time = new Date();
Severity: Major
Found in client/game/ServerCommListener.js - About 1 day to fix

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

    module.exports = function(io, logger) {
    
        io.sockets.on('connection', function (socket) {
            /* A client creates a new game, joins it and waits for other players */
            socket.on('createGame_req', function (data) {
    Severity: Major
    Found in server/ioHandler.js - About 1 day to fix

      Function drawText has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
      Open

      BaseCard.drawText = function(ctx,text,profitConfig,x,y,width) {
          if(typeof(profitConfig) !== 'undefined') {
              for(var i = 0 ; i < profitConfig.length ; i++) {
                  var pf = profitConfig[i];
                  if(text.length > 0 ) {
      Severity: Minor
      Found in client/game/Card.js - About 1 day 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

      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 CardLayouter has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

        function CardLayouter(ctx) {
        
            this.cards = [];
            this.maxWidth = 600;
            this.currentlyExpanded = null;
        Severity: Minor
        Found in client/game/CardLayouter.js - About 7 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 FieldPane has 173 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function FieldPane() {
        
            this.relocateX = 0;  
            this.relocateY = 0;
            this.allElements = [];
        Severity: Major
        Found in client/game/FieldPane.js - About 6 hrs to fix

          Function AuctionPanel has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
          Open

          function AuctionPanel() {
              this.cards = [];
              this.currentlyClicked = null;
              this.selectable = false;
              this.setCards = function(cards) {
          Severity: Minor
          Found in client/game/AuctionPanel.js - About 6 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 ServerCommListener has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

          function ServerCommListener() {    
              var time = null;
              this.showWaitOverlay = function() {
                  $('#overlay').show();
                  time = new Date();
          Severity: Minor
          Found in client/game/ServerCommListener.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 InfoBar has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

          function InfoBar() {
              this.money = -1;
              this.currentDate;
              this.playerNumber = -1;
              this.showLargeInfo = false;    
          Severity: Minor
          Found in client/game/InfoBar.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 storeGame has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              storeGame : function(game, prepare, onSuccess, onFail) {
                  var prepareAndInsert = function(newGame, directInsert) {
                      try {
                          var doInsert = true;
                          if(prepare != null) {
          Severity: Minor
          Found in server/rule_gamemanager.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

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

          Card.forEachField = function(range, field, fields, perField) {
              for(var x = -range ; x <= range ; x++) {
                  for(var y = -range ; y <= range ; y++) {
                      if(x!=0 || y!=0) {
                          var surroundingElement = fields[(field.x+x)+":"+(field.y+y)];
          Severity: Major
          Found in server/cards/card_basecards.js and 1 other location - About 5 hrs to fix
          client/game/FieldPane.js on lines 187..198

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

          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.forEachField = function(range, field, fields, perField) {
                  for(var x = -range ; x <= range ; x++) {
                      for(var y = -range ; y <= range ; y++) {
                          if(x!=0 || y!=0) {
                              var surroundingElement = fields[(field.x+x)+":"+(field.y+y)];
          Severity: Major
          Found in client/game/FieldPane.js and 1 other location - About 5 hrs to fix
          server/cards/card_basecards.js on lines 46..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 135.

          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

          UIServices.getLocalLevelText = function(localLevel) {
              if(localLevel < LOCALLEVEL_MIN_LOWERMIDDLE) {
                  return G.i18n.localLevelText_0;
              } else if(localLevel < LOCALLEVEL_MIN_MIDDLE) {
                  return G.i18n.localLevelText_1;
          Severity: Major
          Found in client/game/UIServices.js and 1 other location - About 4 hrs to fix
          client/game/UIServices.js on lines 11..22

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

          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

          UIServices.getLocalLevelTextShort = function(localLevel) {
              if(localLevel < LOCALLEVEL_MIN_LOWERMIDDLE) {
                  return G.i18n.localLevelTextShort_0;
              } else if(localLevel < LOCALLEVEL_MIN_MIDDLE) {
                  return G.i18n.localLevelTextShort_1;
          Severity: Major
          Found in client/game/UIServices.js and 1 other location - About 4 hrs to fix
          client/game/UIServices.js on lines 23..34

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

          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(!locLev.buildings.in( HouseTypeReverse[field.attachedCard.houseType] )) {                
                          var rnd = parseInt(Math.random() * locLev.buildings.length);
                          field.attachedCard.houseType = HouseType[locLev.buildings[rnd]];
                          field.attachedCard.housePopulation = parseInt(Math.random() * HouseTypeMaxPop[locLev.buildings[rnd]])+1
                      }
          Severity: Major
          Found in server/rule_field.js and 1 other location - About 3 hrs to fix
          server/cards/card_other.js on lines 34..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 107.

          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(field.attachedCard.houseType > HouseType[locLev.buildings[ locLev.buildings.length-1 ]]) {
                              var rnd = parseInt(Math.random() * locLev.buildings.length);
                              field.attachedCard.houseType = HouseType[locLev.buildings[rnd]];
                              field.attachedCard.housePopulation = parseInt(Math.random() * HouseTypeMaxPop[locLev.buildings[rnd]])+1
                          }
          Severity: Major
          Found in server/cards/card_other.js and 1 other location - About 3 hrs to fix
          server/rule_field.js on lines 49..53

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

          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 Card has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

          function Card(id,title,text,actionBit,playType,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 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

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

                  if(typeof(this.localLevelMod) !== 'undefined' && this.localLevelMod != 0) {
                      var t = "S:"+this.localLevelMod;
                      ctx.fillText(t, this.x+this.width-ctx.measureText(t).width-4, this.y+this.height-5);
                  }        
          Severity: Major
          Found in client/game/Card.js and 1 other location - About 3 hrs to fix
          client/game/Card.js on lines 191..194

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

          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(typeof(this.localLevelMod) !== 'undefined' && this.localLevelMod != 0) {
                          var t = "S:"+this.localLevelMod;
                          ctx.fillText(t, this.x+this.width-ctx.measureText(t).width-4, this.y+this.height-5);
                      }        
          Severity: Major
          Found in client/game/Card.js and 1 other location - About 3 hrs to fix
          client/game/Card.js on lines 244..247

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

          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

          Severity
          Category
          Status
          Source
          Language