oglimmer/ggo

View on GitHub

Showing 183 of 183 total issues

Function _clearState has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            function _clearState() {
                _response.partialMessage = "";
                if (_request.id) {
                    clearTimeout(_request.id);
                }
Severity: Minor
Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 1 hr to fix

    Function defineArrayMethodWatcher has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var defineArrayMethodWatcher = function (obj, original, methodName, callback) {
            defineProp(obj, methodName, function () {
                var index = 0;
                var i,newValue, oldValue, response;                        
                // get values before splicing array 
    Severity: Minor
    Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

      Function draw has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Field.prototype.draw = function(ctx, showCoordinates) {
              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/Field.js - About 1 hr to fix

        Function loop has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var loop = function(){
        
                // check for new or deleted props
                for(var i=0; i<lengthsubjects.length; i++) {
        
        
        Severity: Minor
        Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

          Function getObjDiff has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var getObjDiff = function(a, b){
                  var aplus = [],
                  bplus = [];
          
                  if(!(typeof a == "string") && !(typeof b == "string")){
          Severity: Minor
          Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

            Function fn has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    var level,fn = function(prop, action, newValue, oldValue) {
                        var timerID = getTimerID();
                        if (lastTimerID!==timerID) { // check if timer has changed since last update
                            lastTimerID = timerID;
                            change = {
            Severity: Minor
            Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

              Method resolveBattle has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected void resolveBattle(Unit u1, Unit u2, boolean crossing) {
                      int for1 = isFortified(u1);
                      int for2 = isFortified(u2);
                      int sup1 = isSupported(u1);
                      int sup2 = isSupported(u2);

                Function _getPushRequest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            function _getPushRequest(message) {
                                var msg = _getStringMessage(message);
                
                                var rq = {
                                    connected: false,
                Severity: Minor
                Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if (zero(thisX, fx) && minus(thisY, fy) || plus(thisX, fx) && minus(thisY, fy)
                                      || zero(thisX, fx) && plus(thisY, fy) || plus(thisX, fx) && plus(thisY, fy)) {
                                  return true;
                              }
                  Severity: Critical
                  Found in core/src/main/java/de/oglimmer/ggo/logic/util/FieldUtil.java - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (minus(thisX, fx) && minus(thisY, fy) || zero(thisX, fx) && minus(thisY, fy)
                                        || minus(thisX, fx) && plus(thisY, fy) || zero(thisX, fx) && plus(thisY, fy)) {
                                    return true;
                                }
                    Severity: Critical
                    Found in core/src/main/java/de/oglimmer/ggo/logic/util/FieldUtil.java - About 1 hr to fix

                      Function storage has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                          storage: function () {
                                              function onstorage(event) {
                                                  // When a deletion, newValue initialized to null
                                                  if (event.key === name && event.newValue) {
                                                      listener(event.newValue);
                      Severity: Minor
                      Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 1 hr to fix

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

                        class TextBuilder extends BaseBuilder<TextBuilder> {
                        
                            private boolean hideScore;
                            private boolean hideInfo;
                        
                        
                        core/src/main/java/de/oglimmer/ggo/logic/phase/tutorial/TutorialStepFactory.java on lines 369..396
                        core/src/main/java/de/oglimmer/ggo/logic/phase/tutorial/TutorialStepFactory.java on lines 398..425

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

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

                        class DeployBuilder extends BaseBuilder<DeployBuilder> {
                        
                            private UnitType unitType;
                            private Field field;
                        
                        
                        core/src/main/java/de/oglimmer/ggo/logic/phase/tutorial/TutorialStepFactory.java on lines 318..345
                        core/src/main/java/de/oglimmer/ggo/logic/phase/tutorial/TutorialStepFactory.java on lines 398..425

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

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

                        class CombatBuilder extends BaseBuilder<CombatBuilder> {
                        
                            private Field unit;
                            private Field field;
                        
                        
                        core/src/main/java/de/oglimmer/ggo/logic/phase/tutorial/TutorialStepFactory.java on lines 318..345
                        core/src/main/java/de/oglimmer/ggo/logic/phase/tutorial/TutorialStepFactory.java on lines 369..396

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

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

                              var defineGetAndSet = function (obj, propName, getter, setter) {
                                  try {
                                      Object.observe(obj, function(changes) {
                                          changes.forEach(function(change) {
                                              if (change.name === propName) {
                          Severity: Minor
                          Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 1 hr to fix

                            Method getMovableFields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private Set<Field> getMovableFields(CommandCenter cc) {
                                    /*
                                     * A unit can move to all neighbors if no own unit has a FORTIFY or MOVE
                                     * on/to this field
                                     */
                            Severity: Minor
                            Found in core/src/main/java/de/oglimmer/ggo/logic/Unit.java - About 1 hr 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

                            Method draft has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                @Override
                                public void draft() {
                                    DraftPhase draftPhase = (DraftPhase) game.getCurrentPhase();
                                    int cheaptestUnit = UnitType.INFANTERY.getCost();
                                    while (player.getCredits() > cheaptestUnit) {
                            Severity: Minor
                            Found in core/src/main/java/de/oglimmer/ggo/logic/ai/RandomStrategy.java - About 1 hr 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 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 onerror has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                              _sse.onerror = function (message) {
                                                  _debug("sse.onerror");
                                                  clearTimeout(_request.id);
                              
                                                  if (_request.heartbeatTimer) {
                              Severity: Minor
                              Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language