oglimmer/ggo

View on GitHub

Showing 183 of 183 total issues

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

                    atmosphere.util.each(_request.headers, function (name, value) {
                        var h = atmosphere.util.isFunction(value) ? value.call(this, _request, _request, _response) : value;
                        if (h != null) {
                            query += "&" + encodeURIComponent(name) + "=" + encodeURIComponent(h);
                        }
Severity: Major
Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js and 1 other location - About 3 hrs to fix
web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js on lines 1806..1811

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

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

Method adjacent has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static boolean adjacent(Field a, Field b) {
        int thisX = (int) a.getPos().getX();
        int thisY = (int) a.getPos().getY();
        int fx = (int) b.getPos().getX();
        int fy = (int) b.getPos().getY();
Severity: Minor
Found in core/src/main/java/de/oglimmer/ggo/logic/util/FieldUtil.java - 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 open has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                    open: function () {
                        var iframe = doc.createElement("iframe");

                        url = _attachHeaders(rq);
                        if (rq.data !== '') {
Severity: Major
Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 3 hrs to fix

    Function defineWatcher has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var defineWatcher = function (obj, prop, watcher, level) {
            var newWatcher = false;
            var isArr = isArray(obj);
            
            if (!obj.watchers) {
    Severity: Major
    Found in web/src/main/webapp/js/lib/watch-1.3.0.js - About 3 hrs to fix

      Function _f has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  function _f(response, f) {
                      switch (response.state) {
                          case "messageReceived":
                              _debug("Firing onMessage");
                              _requestCount = 0;
      Severity: Major
      Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 2 hrs to fix

        Function onclose has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        _websocket.onclose = function (message) {
                            _debug("websocket.onclose");
                            clearTimeout(_request.id);
                            if (_response.state === 'closed')
                                return;
        Severity: Major
        Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 2 hrs to fix

          Function stringifyJSON has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  stringifyJSON: function (value) {
                      var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, meta = {
                          '\b': '\\b',
                          '\t': '\\t',
                          '\n': '\\n',
          Severity: Major
          Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js - About 2 hrs to fix

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

                var unwatch = function () {
            
                    if (isFunction(arguments[1])) {
                        unwatchAll.apply(this, arguments);
                    } else if (isArray(arguments[1])) {
            Severity: Major
            Found in web/src/main/webapp/js/lib/watch-1.3.0.js and 1 other location - About 2 hrs to fix
            web/src/main/webapp/js/lib/watch-1.3.0.js on lines 181..191

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

            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

                var watch = function () {
            
                    if (isFunction(arguments[1])) {
                        watchAll.apply(this, arguments);
                    } else if (isArray(arguments[1])) {
            Severity: Major
            Found in web/src/main/webapp/js/lib/watch-1.3.0.js and 1 other location - About 2 hrs to fix
            web/src/main/webapp/js/lib/watch-1.3.0.js on lines 262..272

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

            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

            File CombatCommandPhase.java has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package de.oglimmer.ggo.logic.phase;
            
            import java.util.ArrayList;
            import java.util.Collection;
            import java.util.HashMap;

              BasePhase has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              @RequiredArgsConstructor
              abstract public class BasePhase implements de.oglimmer.atmospheremvc.game.Phase {
              
                  private static final long serialVersionUID = 1L;
              
              
              Severity: Minor
              Found in core/src/main/java/de/oglimmer/ggo/logic/phase/BasePhase.java - About 2 hrs to fix

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

                                                            try {
                                                                _response.status = ajaxRequest.status;
                                                                _response.headers = atmosphere.util.parseHeaders(ajaxRequest.getAllResponseHeaders());
                
                                                                _readHeaders(ajaxRequest, _request);
                Severity: Major
                Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js and 1 other location - About 2 hrs to fix
                web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js on lines 2088..2095

                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

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

                                            try {
                                                _response.status = ajaxRequest.status;
                                                _response.headers = atmosphere.util.parseHeaders(ajaxRequest.getAllResponseHeaders());
                
                                                _readHeaders(ajaxRequest, rq);
                Severity: Major
                Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js and 1 other location - About 2 hrs to fix
                web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js on lines 2052..2060

                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

                Method command has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @Override
                    public void command() {
                        CombatCommandPhase combatCommandPhase = (CombatCommandPhase) game.getCurrentPhase();
                        game.getBoard().getFields().stream().filter(f -> f.getUnit() != null)
                                .filter(f -> f.getUnit().getPlayer() == player).map(f -> f.getUnit()).forEach(u -> {
                Severity: Major
                Found in core/src/main/java/de/oglimmer/ggo/logic/ai/RandomStrategy.java - About 2 hrs to fix

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

                                      if (request.connectTimeout > 0) {
                                          request.id = setTimeout(function () {
                                              if (request.requestCount === 0) {
                                                  _clearState();
                                                  _prepareCallback("Connect timeout", "closed", 200, request.transport);
                  Severity: Major
                  Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js and 1 other location - About 2 hrs to fix
                  web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js on lines 2358..2365

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

                  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 (rq.connectTimeout > 0) {
                                              rq.id = setTimeout(function () {
                                                  if (rq.requestCount === 0) {
                                                      _clearState();
                                                      _prepareCallback("Connect timeout", "closed", 200, rq.transport);
                  Severity: Major
                  Found in web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js and 1 other location - About 2 hrs to fix
                  web/src/main/webapp/js/lib/atmosphere-javascript-2.3.2.js on lines 2163..2170

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

                  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

                      protected void killBoth(Unit u1, Unit u2) {
                          addInfo(u1.getPlayer(), "DEFEAT: Your " + u1.getUnitType() + " on " + u1.getDeployedOn().getId()
                                  + " got destroyed by " + u2.getUnitType() + " from " + u2.getDeployedOn().getId() + ".");
                          addInfo(u2.getPlayer(), "DEFEAT: Your " + u2.getUnitType() + " on " + u2.getDeployedOn().getId()
                                  + " got destroyed by " + u1.getUnitType() + " from " + u1.getDeployedOn().getId() + ".");
                  core/src/main/java/de/oglimmer/ggo/logic/battle/BaseBattleResolver.java on lines 92..99

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

                  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

                      protected void killCrossingBoth(Unit u1, Unit u2) {
                          addInfo(u1.getPlayer(), "DEFEAT: Your " + u1.getUnitType() + " on " + u1.getDeployedOn().getId()
                                  + " got destroyed while crossing by " + u2.getUnitType() + " from " + u2.getDeployedOn().getId() + ".");
                          addInfo(u2.getPlayer(), "DEFEAT: Your " + u2.getUnitType() + " on " + u2.getDeployedOn().getId()
                                  + " got destroyed while crossing by " + u1.getUnitType() + " from " + u1.getDeployedOn().getId() + ".");
                  core/src/main/java/de/oglimmer/ggo/logic/battle/BaseBattleResolver.java on lines 109..116

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

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

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

                        protected void killBombarb(Unit unitKilled, Unit killer) {
                            addInfo(unitKilled.getPlayer(),
                                    "DEFEAT: Your " + unitKilled.getUnitType() + " on " + unitKilled.getDeployedOn().getId()
                                            + " got bombarded by " + killer.getUnitType() + " from " + killer.getDeployedOn().getId()
                                            + ".");
                    core/src/main/java/de/oglimmer/ggo/logic/battle/BaseBattleResolver.java on lines 82..90
                    core/src/main/java/de/oglimmer/ggo/logic/battle/BaseBattleResolver.java on lines 101..107

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

                    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