oglimmer/citybuilder

View on GitHub

Showing 157 of 157 total issues

Function CardLayouter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function CardLayouter(ctx) {

    this.cards = [];
    this.maxWidth = 600;
    this.currentlyExpanded = null;
Severity: Major
Found in client/game/CardLayouter.js - About 3 hrs to fix

    Function Card has 82 lines of code (exceeds 25 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: Major
    Found in client/game/Card.js - About 3 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 drawText has 75 lines of code (exceeds 25 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: Major
      Found in client/game/Card.js - About 3 hrs to fix

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

        UIElement.prototype.atPos = function(x, y) {
            if(x >= this.drawX && y >= this.drawY && x <= this.drawX+this.width && y <= this.drawY+this.height) {
                return true;
            }
            return false;
        Severity: Major
        Found in client/game/UIElement.js and 1 other location - About 2 hrs to fix
        client/game/Card.js on lines 101..106

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

        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

        BaseCard.prototype.atPos = function(x, y) {   
            if(x>=this.x && y>=this.y && x<=this.x+this.width && y <=this.y+this.height) {
                return true;
            }
            return false;
        Severity: Major
        Found in client/game/Card.js and 1 other location - About 2 hrs to fix
        client/game/UIElement.js on lines 92..97

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

        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 Global has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Global() {
            this.canvas = document.getElementById('gameCanvas');
            this.ctx = this.canvas.getContext('2d');
            this.uiMode = 0;
            this.playerId = null; // identifier, secret
        Severity: Major
        Found in client/game/Global.js - About 2 hrs to fix

          Function InfoBar has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function InfoBar() {
              this.money = -1;
              this.currentDate;
              this.playerNumber = -1;
              this.showLargeInfo = false;    
          Severity: Major
          Found in client/game/InfoBar.js - About 2 hrs to fix

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

            NewPeopleCard.prototype.play = function(field, player, fields) {
                var changedFields = {};
                NewPeopleCard.newPeople(field, changedFields);
                Card.forEachField(1, field, fields, function(surroundingElement) {
                    NewPeopleCard.newPeople(surroundingElement, changedFields);
            Severity: Major
            Found in server/cards/card_other.js and 1 other location - About 2 hrs to fix
            server/cards/card_other.js on lines 47..54

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

            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

            GentrificationCard.prototype.play = function(field, player, fields) {
                var changedFields = {};
                GentrificationCard.gentrificate(field, changedFields);
                Card.forEachField(1, field, fields, function(surroundingElement) {
                    GentrificationCard.gentrificate(surroundingElement, changedFields);
            Severity: Major
            Found in server/cards/card_other.js and 1 other location - About 2 hrs to fix
            server/cards/card_other.js on lines 189..196

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

            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 AuctionPanel has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function AuctionPanel() {
                this.cards = [];
                this.currentlyClicked = null;
                this.selectable = false;
                this.setCards = function(cards) {
            Severity: Major
            Found in client/game/AuctionPanel.js - About 2 hrs to fix

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

                              fixedAllPlayers.getPlayerByNo = function(playerNo) {
                                  for(var i = 0 ; i < fixedAllPlayers.length ; i++) {
                                      var p = fixedAllPlayers[i];
                                      if(p.no == playerNo) {
                                          return p;
              Severity: Major
              Found in server/rule_playermanager.js and 1 other location - About 2 hrs to fix
              server/rule_playermanager.js on lines 68..76

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

              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

                              fixedAllPlayers.getPlayerById = function(playerId) {
                                  for(var i = 0 ; i < fixedAllPlayers.length ; i++) {
                                      var p = fixedAllPlayers[i];
                                      if(p._id == playerId) {
                                          return p;
              Severity: Major
              Found in server/rule_playermanager.js and 1 other location - About 2 hrs to fix
              server/rule_playermanager.js on lines 59..67

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

              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.type) !== 'undefined') {
                          ctx.fillText(UIServices.getFieldType(this.type), this.x+this.width-ctx.measureText(this.type).width-4, this.y+12);
                      }
              Severity: Major
              Found in client/game/Card.js and 1 other location - About 2 hrs to fix
              client/game/Card.js on lines 182..184

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

              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.type) !== 'undefined') {
                          ctx.fillText(UIServices.getFieldType(this.type), this.x+this.width-ctx.measureText(this.type).width-4, this.y+12);
                      }
              Severity: Major
              Found in client/game/Card.js and 1 other location - About 2 hrs to fix
              client/game/Card.js on lines 237..239

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

              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 GlobalListeners has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function GlobalListeners() {
              
                  this.buttonDown = false;
                  this.moved = false;
                  this.startMoveX=0;
              Severity: Major
              Found in client/game/GlobalListeners.js - About 2 hrs to fix

                Function setBaseFillStyle has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                UIElement.prototype.setBaseFillStyle = function() {
                    switch(this.type) {
                        case -1:/*UNKNWON*/
                            this.fillStyleN = '#333333';
                            break;
                Severity: Major
                Found in client/game/UIElement.js - About 2 hrs to fix

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

                  BaseCard.prototype.Inherits = function(parent) {
                      if(arguments.length > 1) {
                          parent.apply(this, Array.prototype.slice.call(arguments, 1) );
                      } else {      
                          parent.call(this);
                  Severity: Major
                  Found in client/game/Card.js and 1 other location - About 2 hrs to fix
                  client/game/CanvasManager.js on lines 10..16

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

                  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

                  CanvasManager.prototype.Inherits = function(parent) {
                      if(arguments.length > 1) {
                          parent.apply(this, Array.prototype.slice.call(arguments, 1) );
                      } else {      
                          parent.call(this);
                  Severity: Major
                  Found in client/game/CanvasManager.js and 1 other location - About 2 hrs to fix
                  client/game/Card.js on lines 8..14

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

                  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

                  CanvasManager.prototype.add = function(zindex, element) {
                      this.elements.push([zindex,false,element]);
                      this.elements.sort(function(a,b){
                          return a[0]-b[0];
                      });
                  Severity: Major
                  Found in client/game/CanvasManager.js and 1 other location - About 2 hrs to fix
                  client/game/CanvasManager.js on lines 25..30

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

                  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