seeseemelk/MockBukkit

View on GitHub
src/main/java/be/seeseemelk/mockbukkit/inventory/InventoryMock.java

Summary

Maintainability
A
35 mins
Test Coverage

Method addItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public ItemStack addItem(ItemStack item)
    {
        item = item.clone();
        for (int i = 0; i < items.length; i++)
        {
Severity: Minor
Found in src/main/java/be/seeseemelk/mockbukkit/inventory/InventoryMock.java - About 35 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

Change the visibility of this constructor to "protected".
Open

    public InventoryMock(InventoryHolder holder, int size, InventoryType type)

Abstract classes should not have public constructors. Constructors of abstract classes can only be called in constructors of their subclasses. So there is no point in making them public. The protected modifier should be enough.

Noncompliant Code Example

public abstract class AbstractClass1 {
    public AbstractClass1 () { // Noncompliant, has public modifier
        // do something here
    }
}

Compliant Solution

public abstract class AbstractClass2 {
    protected AbstractClass2 () {
        // do something here
    }
}

There are no issues that match your filters.

Category
Status