Mirroar/hivemind

View on GitHub
src/manager.bay.ts

Summary

Maintainability
B
5 hrs
Test Coverage

Function constructor has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(pos: RoomPosition, hasHarvester: boolean) {
        this.pos = pos;
        this.name = encodePosition(pos);
        this._hasHarvester = hasHarvester;
        this.extensions = [];
Severity: Minor
Found in src/manager.bay.ts - About 2 hrs 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 constructor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor(pos: RoomPosition, hasHarvester: boolean) {
        this.pos = pos;
        this.name = encodePosition(pos);
        this._hasHarvester = hasHarvester;
        this.extensions = [];
Severity: Minor
Found in src/manager.bay.ts - About 1 hr to fix

    Function isBlocked has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        isBlocked(): boolean {
            return cache.inHeap('bay-blocked:' + this.name, 100, () => {
                // Do not add extensions to bay if center is blocked by a structure.
                const posStructures = this.pos.lookFor(LOOK_STRUCTURES);
                for (const structure of posStructures) {
    Severity: Minor
    Found in src/manager.bay.ts - About 1 hr to fix

      Function refillFrom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          refillFrom(creep: Creep) {
              const needsRefill = this.getStructuresNeedingRefill();
              if (needsRefill.length === 0) return false;
      
              const target = _.min(needsRefill, extension => (bayStructures as string[]).indexOf(extension.structureType));
      Severity: Minor
      Found in src/manager.bay.ts - 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