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);
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());
- 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 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);
- 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 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);
Avoid deeply nested control flow statements. Open
if (spawn) {
fieldDescription[i][j] = FieldDescription.SPAWN;
spawn = false;
} else {
fieldDescription[i][j] = FieldDescription.PATH;
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) {
- 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 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) {
- 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 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();
- 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 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();
- 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 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)
- 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 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) {
- 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false; // Doesn't fall in any of the above cases
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
if (o4 == 0 && onSegment(p2, q1, q2)) return true;
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);
}
- 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 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() {
- 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"