oglimmer/ggo

View on GitHub
core/src/main/java/de/oglimmer/ggo/logic/Unit.java

Summary

Maintainability
B
5 hrs
Test Coverage

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.
Severity: Minor
Found in core/src/main/java/de/oglimmer/ggo/logic/Unit.java - About 1 hr 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 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
         */
Severity: Minor
Found in core/src/main/java/de/oglimmer/ggo/logic/Unit.java - About 1 hr 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 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);
        }
Severity: Minor
Found in core/src/main/java/de/oglimmer/ggo/logic/Unit.java - About 1 hr 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 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);
        }
Severity: Minor
Found in core/src/main/java/de/oglimmer/ggo/logic/Unit.java - About 1 hr to fix

    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)
    Severity: Minor
    Found in core/src/main/java/de/oglimmer/ggo/logic/Unit.java - About 25 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

    There are no issues that match your filters.

    Category
    Status