niwa99/Tower-Defense

View on GitHub

Showing 39 of 88 total issues

Method buildTower has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void buildTower(TowerType type, int level, Position pos) {
        if (subMoney(type.getPrice()) && getMapStructure().getField(pos).getFieldDescription() == FieldDescription.FREE) {
            switch(type) {
                case ARTILLERY:
                    TowerArtillery newArtillery = new TowerArtillery(getMapStructure().getField(pos), level, gameActivity);
Severity: Minor
Found in app/src/main/java/de/dhbw/game/Game.java - About 1 hr to fix

    Method move has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public boolean move(MapStructure map) {
            if (actualField == null) {
                actualField = getEnemyField(map);
                progress++;
                moveToPosition(actualField.getSpawnPoint());
    Severity: Minor
    Found in app/src/main/java/de/dhbw/map/objects/enemy/AEnemy.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 doIntersect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        static boolean doIntersect(Position p1, Position q1, Position p2, Position q2) {
            // Find the four orientations needed for general and
            // special cases
            int o1 = orientation(p1, q1, p2);
            int o2 = orientation(p1, q1, q2);
    Severity: Minor
    Found in app/src/main/java/de/dhbw/map/objects/bullet/LaserRay.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 initializeView has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public LinearLayout initializeView() {
    
            LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.menu_upgrade_and_sell, null);
    
            setHeader(towerType + " lvl " + level);
    Severity: Minor
    Found in app/src/main/java/de/dhbw/game/popups/MenuUpgradeAndSell.java - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              if (spawn) {
                                  fieldDescription[i][j] = FieldDescription.SPAWN;
                                  spawn = false;
                              } else {
                                  fieldDescription[i][j] = FieldDescription.PATH;
      Severity: Major
      Found in app/src/main/java/de/dhbw/map/structure/MapStructure.java - About 45 mins to fix

        Method getNearestEnemy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public AEnemy getNearestEnemy(Position actualPosition, List<AEnemy> enemies) {
                if (!enemies.isEmpty()) {
                    Map<AEnemy, Integer> distanceToEnemy = new HashMap<>();
        
                    for (AEnemy enemy : enemies) {
        Severity: Minor
        Found in app/src/main/java/de/dhbw/map/objects/tower/ATower.java - About 45 mins 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 getEnemiesToHit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public Map<AEnemy, Integer> getEnemiesToHit() {
                Map<AEnemy, Integer> enemiesInExplosionRange = new HashMap<AEnemy, Integer>();
                targetEnemy.getPosition();
                List<AEnemy> hitableEnemies = allEnemies.stream().filter(e -> ATower.filterPlaneIfTowerCannotFocus(TowerType.BOOMBASTIC, e)).collect(Collectors.toList());
                for (AEnemy e : hitableEnemies) {
        Severity: Minor
        Found in app/src/main/java/de/dhbw/map/objects/bullet/Bomb.java - About 35 mins 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 toggle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void toggle(Settings setting, boolean on) {
                if(setting==Settings.MUSIC){
                    if(on){
                        mediaPlayer.start();
        Severity: Minor
        Found in app/src/main/java/de/dhbw/activities/MainActivity.java - About 35 mins 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 startMusicPlayer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public void startMusicPlayer(Activity activity){
                this.isStarted=true;
                if(timer!=null){
                    timer.cancel();
                    timerTask.cancel();
        Severity: Minor
        Found in app/src/main/java/de/dhbw/game/MusicPlayer.java - About 35 mins 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 equals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public boolean equals(Object obj) {
                if (this == obj)
                    return true;
                if (obj == null)
        Severity: Minor
        Found in app/src/main/java/de/dhbw/map/structure/Field.java - About 35 mins 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 performMoneyUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void performMoneyUpdate(int money) {
                for(int i = 0; i < getMenuLayout().getChildCount(); i++){
                    LinearLayout linearLayout = getMenuLayout().getChildAt(i).findViewById(R.id.linearLayoutTower);
                    if(linearLayout!=null) {
        Severity: Minor
        Found in app/src/main/java/de/dhbw/game/popups/MenuTowerSelection.java - About 35 mins 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

        Avoid too many return statements within this method.
        Open

                    return false;
        Severity: Major
        Found in app/src/main/java/de/dhbw/map/structure/Field.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return false;
          Severity: Major
          Found in app/src/main/java/de/dhbw/map/structure/Field.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false; // Doesn't fall in any of the above cases
            Severity: Major
            Found in app/src/main/java/de/dhbw/map/objects/bullet/LaserRay.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return false;
              Severity: Major
              Found in app/src/main/java/de/dhbw/map/structure/Field.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return true;
                Severity: Major
                Found in app/src/main/java/de/dhbw/map/structure/Field.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          if (o4 == 0 && onSegment(p2, q1, q2)) return true;
                  Severity: Major
                  Found in app/src/main/java/de/dhbw/map/objects/bullet/LaserRay.java - About 30 mins to fix

                    Method toggle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public void toggle(boolean on, Activity activity) {
                            this.on=on;
                            if(on && !mediaPlayer.isPlaying()){
                                startMusicPlayer(activity);
                            }
                    Severity: Minor
                    Found in app/src/main/java/de/dhbw/game/MusicPlayer.java - About 25 mins 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 startEnemyMovement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public void startEnemyMovement(AEnemy enemy) {
                            if(matchFieldTimer.isCanceled()){
                                return;
                            }
                                TimerTask timerTask = new TimerTask() {
                    Severity: Minor
                    Found in app/src/main/java/de/dhbw/map/matchfield/MatchField.java - About 25 mins 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

                    Severity
                    Category
                    Status
                    Source
                    Language