oglimmer/ggo

View on GitHub

Showing 102 of 183 total issues

Method resolveBattle has a Cognitive Complexity of 12 (exceeds 5 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);

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

            function _attachHeaders(request, url) {
                var rq = _request;
                if ((request != null) && (typeof (request) !== 'undefined')) {
                    rq = request;
                }
Severity: Minor
Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 1 hr to fix

    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

            HandItem.prototype.draw = function(ctx, x, y) {
                this.width = Constants.size.width*.8;
                this.height = Constants.size.height*.8;
                this.x = x;
                this.y = y;
        Severity: Minor
        Found in web/src/main/webapp/js/app/HandItem.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

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

                                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

                                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

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