niwa99/Tower-Defense

View on GitHub

Showing 88 of 88 total issues

Identical blocks of code found in 5 locations. Consider refactoring.
Open

                case BOOMBASTIC:
                    TowerBoombastic newBoombastic = new TowerBoombastic(getMapStructure().getField(pos), level, gameActivity);
                    getMatchField().addTower(newBoombastic);
                    getMapStructure().getField(pos).setFieldDescription(FieldDescription.TOWER);
                    break;
Severity: Major
Found in app/src/main/java/de/dhbw/game/Game.java and 4 other locations - About 35 mins to fix
app/src/main/java/de/dhbw/game/Game.java on lines 257..261
app/src/main/java/de/dhbw/game/Game.java on lines 262..266
app/src/main/java/de/dhbw/game/Game.java on lines 272..276
app/src/main/java/de/dhbw/game/Game.java on lines 277..281

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

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

    private static int getFreezerFirerateByLevel(int level) {
        switch (level) {
            case 1: return TOWER_FREEZER_LEVEL_1_FIRERATE_IN_SECONDS;
            case 2: return TOWER_FREEZER_LEVEL_2_FIRERATE_IN_SECONDS;
            case 3: return TOWER_FREEZER_LEVEL_3_FIRERATE_IN_SECONDS;
Severity: Major
Found in app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java and 20 other locations - About 35 mins to fix
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 85..93
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 100..108
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 115..123
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 130..138
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 114..122
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 174..182
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 97..105
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 117..125
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 137..145
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 157..165
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 91..99
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 106..114
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 121..129
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 136..144

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

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

Identical blocks of code found in 5 locations. Consider refactoring.
Open

                case PLASMARIZER:
                    TowerPlasmarizer newPlasmarizer = new TowerPlasmarizer(getMapStructure().getField(pos), level, gameActivity);
                    getMatchField().addTower(newPlasmarizer);
                    getMapStructure().getField(pos).setFieldDescription(FieldDescription.TOWER);
                    break;
Severity: Major
Found in app/src/main/java/de/dhbw/game/Game.java and 4 other locations - About 35 mins to fix
app/src/main/java/de/dhbw/game/Game.java on lines 257..261
app/src/main/java/de/dhbw/game/Game.java on lines 262..266
app/src/main/java/de/dhbw/game/Game.java on lines 267..271
app/src/main/java/de/dhbw/game/Game.java on lines 277..281

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

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

    private static int getPlasmarizerDamageByLevel(int level) {
        switch (level) {
            case 1: return TOWER_PLASMARIZER_LEVEL_1_DAMAGE;
            case 2: return TOWER_PLASMARIZER_LEVEL_2_DAMAGE;
            case 3: return TOWER_PLASMARIZER_LEVEL_3_DAMAGE;
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 85..93
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 100..108
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 115..123
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 130..138
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 114..122
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 174..182
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 189..197
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 97..105
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 117..125
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 137..145
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 157..165
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 91..99
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 121..129
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 136..144

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

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

    private static int getPlasmarizerFirerateByLevel(int level) {
        switch (level) {
            case 1: return TOWER_PLASMARIZER_LEVEL_1_FIRERATE_IN_SECONDS;
            case 2: return TOWER_PLASMARIZER_LEVEL_2_FIRERATE_IN_SECONDS;
            case 3: return TOWER_PLASMARIZER_LEVEL_3_FIRERATE_IN_SECONDS;
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 85..93
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 100..108
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 115..123
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 130..138
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 114..122
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 174..182
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 189..197
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 97..105
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 117..125
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 137..145
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 157..165
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 91..99
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 106..114
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 121..129

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

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

    private static int getFreezerSlownessByLevel(int level) {
        switch (level) {
            case 1: return TOWER_FREEZER_LEVEL_1_SLOWNESS;
            case 2: return TOWER_FREEZER_LEVEL_2_SLOWNESS;
            case 3: return TOWER_FREEZER_LEVEL_3_SLOWNESS;
Severity: Major
Found in app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java and 20 other locations - About 35 mins to fix
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 85..93
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 100..108
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 115..123
app/src/main/java/de/dhbw/map/objects/tower/TowerArtillery.java on lines 130..138
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 114..122
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 144..152
app/src/main/java/de/dhbw/map/objects/tower/TowerBoombastic.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 129..137
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 159..167
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 174..182
app/src/main/java/de/dhbw/map/objects/tower/TowerFreezer.java on lines 189..197
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 97..105
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 117..125
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 137..145
app/src/main/java/de/dhbw/map/objects/tower/TowerLaser.java on lines 157..165
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 91..99
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 106..114
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 121..129
app/src/main/java/de/dhbw/map/objects/tower/TowerPlasmarizer.java on lines 136..144

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

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

                case PLANE:
                    for (int i = 0; i < wave.getAmount(); i++) {
                        addEnemy(new Plane(wave.getEnemyType().getLabel(), wave.getLevel(), gameActivity));
                    }
                    break;
Severity: Major
Found in app/src/main/java/de/dhbw/game/wave/Wave.java and 3 other locations - About 35 mins to fix
app/src/main/java/de/dhbw/game/wave/Wave.java on lines 29..33
app/src/main/java/de/dhbw/game/wave/Wave.java on lines 34..38
app/src/main/java/de/dhbw/game/wave/Wave.java on lines 44..48

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

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

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

    public Tank(String label, int level, ImageView image, GameActivity gameActivity) {
        super(label, UUID.randomUUID(), getTankHealthpointsByLevel(level), getTankSpeedByLevel(level), getTankValueByLevel(level), getTankLifePointsCostsByLevel(level), gameActivity, EnemyType.TANK, DRAWABLE_TANK, DRAWABLE_TANK_HITTED);
        timer = new Timer();
    }
Severity: Minor
Found in app/src/main/java/de/dhbw/map/objects/enemy/Tank.java and 1 other location - About 35 mins to fix
app/src/main/java/de/dhbw/map/objects/enemy/Tank.java on lines 25..28

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

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

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

    public Tank(String label, int level, GameActivity gameActivity) {
        super(label, UUID.randomUUID(), getTankHealthpointsByLevel(level), getTankSpeedByLevel(level), getTankValueByLevel(level), getTankLifePointsCostsByLevel(level), gameActivity, EnemyType.TANK, DRAWABLE_TANK, DRAWABLE_TANK_HITTED);
        timer = new Timer();
    }
Severity: Minor
Found in app/src/main/java/de/dhbw/map/objects/enemy/Tank.java and 1 other location - About 35 mins to fix
app/src/main/java/de/dhbw/map/objects/enemy/Tank.java on lines 49..52

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

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 Car(String label, int level, GameActivity gameActivity) {
        super(label, UUID.randomUUID(), getCarHealthpointsByLevel(level), getCarSpeedByLevel(level), getCarValueByLevel(level), getCarLifePointsCostsByLevel(level), gameActivity, EnemyType.CAR, DRAWABLE_CAR, DRAWABLE_CAR_HITTED);
    }
Severity: Minor
Found in app/src/main/java/de/dhbw/map/objects/enemy/Car.java and 1 other location - About 30 mins to fix
app/src/main/java/de/dhbw/map/objects/enemy/Plane.java on lines 27..29

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

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 Plane(String label, int level, GameActivity gameActivity) {
        super(label, UUID.randomUUID(), getPlaneHealthpointsByLevel(level), getPlaneSpeedByLevel(level), getPlaneValueByLevel(level), getPlaneLifePointsCostsByLevel(level), gameActivity, EnemyType.PLANE, DRAWABLE_PLANE, DRAWABLE_PLANE_HITTED);
    }
Severity: Minor
Found in app/src/main/java/de/dhbw/map/objects/enemy/Plane.java and 1 other location - About 30 mins to fix
app/src/main/java/de/dhbw/map/objects/enemy/Car.java on lines 24..26

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

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 Plane(String label, int level, GameActivity gameActivity, EnemyView enemyView) {
        super(label, UUID.randomUUID(), getPlaneHealthpointsByLevel(level), getPlaneSpeedByLevel(level), getPlaneValueByLevel(level), getPlaneLifePointsCostsByLevel(level), gameActivity, EnemyType.PLANE, enemyView);
    }
Severity: Minor
Found in app/src/main/java/de/dhbw/map/objects/enemy/Plane.java and 1 other location - About 30 mins to fix
app/src/main/java/de/dhbw/map/objects/enemy/Car.java on lines 35..37

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

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 Car(String label, int level, GameActivity gameActivity, EnemyView enemyView) {
        super(label, UUID.randomUUID(), getCarHealthpointsByLevel(level), getCarSpeedByLevel(level), getCarValueByLevel(level), getCarLifePointsCostsByLevel(level), gameActivity, EnemyType.CAR, enemyView);
    }
Severity: Minor
Found in app/src/main/java/de/dhbw/map/objects/enemy/Car.java and 1 other location - About 30 mins to fix
app/src/main/java/de/dhbw/map/objects/enemy/Plane.java on lines 38..40

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

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

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