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();
- Read upRead up
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;
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);
Game
has 45 methods (exceeds 20 allowed). Consider refactoring. Open
public class Game {
private GameActivity gameActivity;
private MapStructure mapStructure;
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) {
- Read upRead up
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);
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;
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;
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);
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();
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;
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;
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
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++) {
- Read upRead up
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;
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76