niwa99/Tower-Defense

View on GitHub

Showing 88 of 88 total issues

Method generateButtonsOnMap has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    private void generateButtonsOnMap() {

        List<Button> mapButtons = new ArrayList<>();
        View.OnClickListener listener = view -> {
            Optional<Button> button = mapButtons.stream().filter(e -> view.getTransitionName().equals(e.getTransitionName())).findFirst();
Severity: Minor
Found in app/src/main/java/de/dhbw/game/Game.java - About 1 day 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

File Game.java has 512 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package de.dhbw.game;

import android.app.AlertDialog;
import android.content.Intent;
import android.view.View;
Severity: Major
Found in app/src/main/java/de/dhbw/game/Game.java - About 1 day to fix

    Method create has 156 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public void create(GameActivity gameActivity) {
            Wave wave1 = new Wave(waveSpeed);
            wave1.addWaveCompositions(w1_Plane);
            wave1.generate(gameActivity);
    Severity: Major
    Found in app/src/main/java/de/dhbw/game/match/HardMatch.java - About 6 hrs to fix

      Game has 45 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class Game {
      
          private GameActivity gameActivity;
      
          private MapStructure mapStructure;
      Severity: Minor
      Found in app/src/main/java/de/dhbw/game/Game.java - About 6 hrs to fix

        Method calculatePath has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

            public static int calculatePath(float xCoord, float yCoord) {
        
                int pathImage = DRAWABLE_PATH_HORIZONTAL;
                int pathNumber = getPathNumber(xCoord, yCoord);
                if (pathNumber != 0 && pathNumber != 20) {
        Severity: Minor
        Found in app/src/main/java/de/dhbw/map/structure/MapStructure.java - About 5 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

        Method create has 125 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public void create(GameActivity gameActivity) {
        
                Wave wave1 = new Wave(waveSpeed);
                wave1.addWaveCompositions(w1_Tank);
        Severity: Major
        Found in app/src/main/java/de/dhbw/game/match/MediumMatch.java - About 5 hrs to fix

          ATower has 31 methods (exceeds 20 allowed). Consider refactoring.
          Open

          public abstract class ATower extends ATimerUsage {
          
              private UUID id;
              private TowerType towerType;
              private int level;
          Severity: Minor
          Found in app/src/main/java/de/dhbw/map/objects/tower/ATower.java - About 3 hrs to fix

            AEnemy has 31 methods (exceeds 20 allowed). Consider refactoring.
            Open

            public abstract class AEnemy {
                private String label;
                private UUID uuid;
                private boolean isPaused = false;
                private int value;
            Severity: Minor
            Found in app/src/main/java/de/dhbw/map/objects/enemy/AEnemy.java - About 3 hrs to fix

              Method create has 94 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Override
                  public void create(GameActivity gameActivity) {
              
                      Wave wave1 = new Wave(waveSpeed);
                      wave1.addWaveCompositions(w1_Car);
              Severity: Major
              Found in app/src/main/java/de/dhbw/game/match/EasyMatch.java - About 3 hrs to fix

                Method generateButtonsOnMap has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private void generateButtonsOnMap() {
                
                        List<Button> mapButtons = new ArrayList<>();
                        View.OnClickListener listener = view -> {
                            Optional<Button> button = mapButtons.stream().filter(e -> view.getTransitionName().equals(e.getTransitionName())).findFirst();
                Severity: Major
                Found in app/src/main/java/de/dhbw/game/Game.java - About 3 hrs to fix

                  MatchField has 27 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public class MatchField {
                  
                      private final GameActivity gameActivity;
                      private List<AEnemy> enemies;
                      private List<ATower> towers;
                  Severity: Minor
                  Found in app/src/main/java/de/dhbw/map/matchfield/MatchField.java - About 3 hrs to fix

                    GameActivity has 26 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    public class GameActivity extends AppCompatActivity implements IStatusBar {
                    
                        private static final boolean AUTO_HIDE = true;
                        private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
                        private static final int UI_ANIMATION_DELAY = 300;
                    Severity: Minor
                    Found in app/src/main/java/de/dhbw/activities/GameActivity.java - About 3 hrs to fix

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

                          private void setMediumInformation() {
                              textDifficultyHeader.setText(R.string.difficulty_medium);
                              textDifficultyDescription.setText(R.string.difficulty_medium_description);
                              textValueMaxWave.setText(PreferenceManager.getStatisticsValue(PreferenceManager.Statistics.MEDIUM_MAX_WAVE));
                              textValueEnemiesKilled.setText(PreferenceManager.getStatisticsValue(PreferenceManager.Statistics.MEDIUM_ENEMIES_KILLED));
                      app/src/main/java/de/dhbw/activities/DifficultyFragment.java on lines 62..73
                      app/src/main/java/de/dhbw/activities/DifficultyFragment.java on lines 88..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 163.

                      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

                          private void setEasyInformation() {
                              textDifficultyHeader.setText(R.string.difficulty_easy);
                              textDifficultyDescription.setText(R.string.difficulty_easy_description);
                              textValueMaxWave.setText(PreferenceManager.getStatisticsValue(PreferenceManager.Statistics.EASY_MAX_WAVE));
                              textValueEnemiesKilled.setText(PreferenceManager.getStatisticsValue(PreferenceManager.Statistics.EASY_ENEMIES_KILLED));
                      app/src/main/java/de/dhbw/activities/DifficultyFragment.java on lines 75..86
                      app/src/main/java/de/dhbw/activities/DifficultyFragment.java on lines 88..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 163.

                      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

                          private void setHardInformation() {
                              textDifficultyHeader.setText(R.string.difficulty_hard);
                              textDifficultyDescription.setText(R.string.difficulty_hard_description);
                              textValueMaxWave.setText(PreferenceManager.getStatisticsValue(PreferenceManager.Statistics.HARD_MAX_WAVE));
                              textValueEnemiesKilled.setText(PreferenceManager.getStatisticsValue(PreferenceManager.Statistics.HARD_ENEMIES_KILLED));
                      app/src/main/java/de/dhbw/activities/DifficultyFragment.java on lines 62..73
                      app/src/main/java/de/dhbw/activities/DifficultyFragment.java on lines 75..86

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

                      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 MatchField.java has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      package de.dhbw.map.matchfield;
                      
                      import android.view.View;
                      import android.widget.ImageView;
                      
                      
                      Severity: Minor
                      Found in app/src/main/java/de/dhbw/map/matchfield/MatchField.java - About 2 hrs to fix

                        Method createPath has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private FieldDescription[][] createPath() {
                                // There is only one fixed Path with the Coordinates generated as following
                                FieldDescription[][] fieldDescription = new FieldDescription[AMOUNT_COLUMNS][AMOUNT_ROWS];
                                boolean spawn = true;
                                for (int i = 0; i < 11; i++) {
                        Severity: Minor
                        Found in app/src/main/java/de/dhbw/map/structure/MapStructure.java - About 2 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

                        File HardMatch.java has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        package de.dhbw.game.match;
                        
                        import de.dhbw.activities.GameActivity;
                        import de.dhbw.game.Difficulty;
                        import de.dhbw.game.EnemyType;
                        Severity: Minor
                        Found in app/src/main/java/de/dhbw/game/match/HardMatch.java - About 2 hrs to fix

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

                              public TowerBoombastic(Field field, int level, GameActivity gameActivity) {
                                  super(UUID.randomUUID(), TowerType.BOOMBASTIC,
                                          level, getTowerBoombasticCostsByLevel(level),
                                          getTowerBoombasticDamageByLevel(level), getTowerBoombasticRangeByLevel(level), getTowerBoombasticFirerateByLevel(level), field, gameActivity);
                          
                          
                          app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 44..63

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

                          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

                              public TowerLaser(Field field, int level, GameActivity gameActivity) {
                                  super(UUID.randomUUID(), TowerType.ASSAULTLASER, level, getLaserCostsByLevel(level), getLaserDamageByLevel(level),
                                          getLaserRangeByLevel(level), getLaserFireRateByLevel(level), field, gameActivity);
                          
                                  ImageView baseImage = new ImageView(gameActivity);
                          Severity: Major
                          Found in app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java and 1 other location - About 2 hrs to fix
                          app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 44..62

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

                          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