oglimmer/ggo

View on GitHub
web/src/main/webapp/js/app/Unit.js

Summary

Maintainability
F
3 days
Test Coverage

Function draw0 has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Unit.prototype.draw0 = function(ctx) {
        var x = this.x;
        var y = this.y;
        var width = this.width;
        var height = this.height;
Severity: Minor
Found in web/src/main/webapp/js/app/Unit.js - About 1 hr to fix

    Function draw1 has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Unit.prototype.draw1 = function(ctx) {
            var x = this.x;
            var y = this.y;
            var width = this.width;
            var height = this.height;
    Severity: Minor
    Found in web/src/main/webapp/js/app/Unit.js - About 1 hr to fix

      Function drawArrow has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function drawArrow(ctx, fromx, fromy, tox, toy, color, onlyHeads){
              //variables to be used when creating the arrow
              var headlen = 4;
      
              var angle = Math.atan2(toy-fromy,tox-fromx);
      Severity: Minor
      Found in web/src/main/webapp/js/app/Unit.js - About 1 hr to fix

        Function drawArrow has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            function drawArrow(ctx, fromx, fromy, tox, toy, color, onlyHeads){
        Severity: Major
        Found in web/src/main/webapp/js/app/Unit.js - About 50 mins to fix

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

                      if(this.command.commandType != "F") {
                          var targetFieldId = this.command.x+":"+this.command.y;
                          var field = globalData.model.boardState.corToFields[targetFieldId];
                          var color;
                          switch(this.command.commandType) {
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 1 other location - About 5 hrs to fix
          web/src/main/webapp/js/app/Unit.js on lines 90..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 137.

          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

                      } else {
                          var targetFieldId = this.command.x+":"+this.command.y;
                          var field = globalData.model.boardState.corToFields[targetFieldId];
                          var color;
                          switch(this.command.commandType) {
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 1 other location - About 5 hrs to fix
          web/src/main/webapp/js/app/Unit.js on lines 119..135

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

          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

                  ctx.lineTo(tox-headlen*Math.cos(angle-Math.PI/7),toy-headlen*Math.sin(angle-Math.PI/7));
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 1 other location - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 188..188

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

          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

                  ctx.lineTo(tox-headlen*Math.cos(angle-Math.PI/7),toy-headlen*Math.sin(angle-Math.PI/7));
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 1 other location - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 181..181

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

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

                      case Constants.UNIT_TYPE_TANK:
                          var img=document.getElementById("tank_"+this.color);
                          ctx.drawImage(img,cx-img.width*.5,cy - img.height*.5);
                          break;
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 5 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 47..50
          web/src/main/webapp/js/app/Unit.js on lines 55..58
          web/src/main/webapp/js/app/Unit.js on lines 59..62
          web/src/main/webapp/js/app/Unit.js on lines 63..66
          web/src/main/webapp/js/app/Unit.js on lines 67..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 69.

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

                      case Constants.UNIT_TYPE_ARTILLERY:
                          var img=document.getElementById("artillery_"+this.color);
                          ctx.drawImage(img,cx-img.width*.5,cy - img.height*.5);
                          break;
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 5 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 47..50
          web/src/main/webapp/js/app/Unit.js on lines 51..54
          web/src/main/webapp/js/app/Unit.js on lines 55..58
          web/src/main/webapp/js/app/Unit.js on lines 59..62
          web/src/main/webapp/js/app/Unit.js on lines 67..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 69.

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

                      case Constants.UNIT_TYPE_INFANTRY:
                          var img=document.getElementById("infantry_"+this.color);
                          ctx.drawImage(img,cx-img.width*.5,cy - img.height*.5);
                          break;
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 5 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 51..54
          web/src/main/webapp/js/app/Unit.js on lines 55..58
          web/src/main/webapp/js/app/Unit.js on lines 59..62
          web/src/main/webapp/js/app/Unit.js on lines 63..66
          web/src/main/webapp/js/app/Unit.js on lines 67..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 69.

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

                      case Constants.UNIT_TYPE_AIRBORNE:
                          var img=document.getElementById("airborne_"+this.color);
                          ctx.drawImage(img,cx-img.width*.5,cy - img.height*.5);
                          break;
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 5 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 47..50
          web/src/main/webapp/js/app/Unit.js on lines 51..54
          web/src/main/webapp/js/app/Unit.js on lines 59..62
          web/src/main/webapp/js/app/Unit.js on lines 63..66
          web/src/main/webapp/js/app/Unit.js on lines 67..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 69.

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

                      case Constants.UNIT_TYPE_CITY:
                          var img=document.getElementById("city_"+this.color);
                          ctx.drawImage(img,cx-img.width*.5,cy - img.height*.5);
                          break;
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 5 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 47..50
          web/src/main/webapp/js/app/Unit.js on lines 51..54
          web/src/main/webapp/js/app/Unit.js on lines 55..58
          web/src/main/webapp/js/app/Unit.js on lines 59..62
          web/src/main/webapp/js/app/Unit.js on lines 63..66

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

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

                      case Constants.UNIT_TYPE_HELICOPTER:
                          var img=document.getElementById("helicopter_"+this.color);
                          ctx.drawImage(img,cx-img.width*.5,cy - img.height*.5);
                          break;
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 5 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Unit.js on lines 47..50
          web/src/main/webapp/js/app/Unit.js on lines 51..54
          web/src/main/webapp/js/app/Unit.js on lines 55..58
          web/src/main/webapp/js/app/Unit.js on lines 63..66
          web/src/main/webapp/js/app/Unit.js on lines 67..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 69.

          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

              Unit.prototype.onSelect = function() {
                  if(this.selectable){
                      communication.send({
                          pid: globalData.playerId,
                          cmd: 'selectUnit',
          Severity: Major
          Found in web/src/main/webapp/js/app/Unit.js and 3 other locations - About 1 hr to fix
          web/src/main/webapp/js/app/Button.js on lines 56..64
          web/src/main/webapp/js/app/Field.js on lines 76..84
          web/src/main/webapp/js/app/HandItem.js on lines 77..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 66.

          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

          There are no issues that match your filters.

          Category
          Status