Method getSupportableFields
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public Set<Field> getSupportableFields(CommandCenter cc) {
assert this.unitType != UnitType.ARTILLERY;
/*
* A unit can support a neighbor if an own unit is currently there and
* not moving away.
- 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 getMovableFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private Set<Field> getMovableFields(CommandCenter cc) {
/*
* A unit can move to all neighbors if no own unit has a FORTIFY or MOVE
* on/to this field
*/
- 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 getPossibleCommandTypes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public Set<CommandType> getPossibleCommandTypes(CommandCenter cc, Field targetField) {
Set<CommandType> possibleCommands = new HashSet<>();
if (getMovableFields(cc).contains(targetField)) {
possibleCommands.add(CommandType.MOVE);
}
- 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 getPossibleCommandTypes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Set<CommandType> getPossibleCommandTypes(CommandCenter cc, Field targetField) {
Set<CommandType> possibleCommands = new HashSet<>();
if (getMovableFields(cc).contains(targetField)) {
possibleCommands.add(CommandType.MOVE);
}
Method getTargetableFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public Set<Field> getTargetableFields() {
assert this.unitType == UnitType.ARTILLERY || this.unitType == UnitType.HELICOPTER;
/*
* A unit can target a neighbor if an enemy unit is on that field (don't
* care about enemy commands)
- 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"