Mirroar/hivemind

View on GitHub
src/role/caravan-trader.ts

Summary

Maintainability
A
3 hrs
Test Coverage

Function chooseTargetRoom has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    chooseTargetRoom(creep: CaravanTraderCreep) {
        // Go to first caravan room that we can reach in time.
        if (!hivemind.segmentMemory.isReady()) return;

        const mesh = new NavMesh();
Severity: Minor
Found in src/role/caravan-trader.ts - 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

Function chooseFollowUpRoom has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    chooseFollowUpRoom(creep: CaravanTraderCreep) {
        // Go to room the caravan is supposed to be in.
        if (!hivemind.segmentMemory.isReady()) return;

        const caravanInfo = Memory.strategy.caravans[creep.memory.target];
Severity: Minor
Found in src/role/caravan-trader.ts - About 45 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

Function performDeliver has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    performDeliver(creep: CaravanTraderCreep) {
        if (!creep.heapMemory.targetRoom) this.chooseTargetRoom(creep);
        if (!creep.heapMemory.targetRoom) return;

        const targetPos = new RoomPosition(25, 25, creep.heapMemory.targetRoom);
Severity: Minor
Found in src/role/caravan-trader.ts - 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

Avoid too many return statements within this function.
Open

            return;
Severity: Major
Found in src/role/caravan-trader.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return;
    Severity: Major
    Found in src/role/caravan-trader.ts - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status