ursinn/DeadByDaylightMC

View on GitHub
src/main/java/noahnok/dbdl/files/game/ExitGate.java

Summary

Maintainability
A
55 mins
Test Coverage

Method getRows has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private List<List<Location>> getRows() {
        int lowestY = 400;
        for (Location loc : this.locs) {
            if (loc.getY() <= lowestY) {
                lowestY = loc.getBlockY();
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/ExitGate.java - About 55 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

Rename "locs" which hides the field declared at line 22.
Open

        for (final List<Location> locs : getRows()) {

Overriding or shadowing a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of code. Further, it could lead maintainers to introduce bugs because they think they're using one variable but are really using another.

Noncompliant Code Example

class Foo {
  public int myField;

  public void doSomething() {
    int myField = 0;
    ...
  }
}

See

There are no issues that match your filters.

Category
Status