Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

File main.ts has 301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global RawMemory */

// Make sure game object prototypes are enhanced.
import {ErrorMapper} from 'utils/ErrorMapper';

Severity: Minor
Found in src/main.ts - About 3 hrs to fix

    Function performMilitaryAttack has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        performMilitaryAttack(creep: BrawlerCreep) {
            if (creep.memory.order) {
                // Attack ordered target first.
                const target = Game.getObjectById<Creep | AnyOwnedStructure>(creep.memory.order.target);
    
    
    Severity: Minor
    Found in src/role/brawler.ts - About 3 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 getBaseUpgraderAmount has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        getBaseUpgraderAmount(room: Room): number {
            // Early on, builders will take care of upgrading once necessary
            // structures have been built.
            if (!room.storage && !room.terminal) return 0;
    
    
    Severity: Minor
    Found in src/spawn-role/upgrader.ts - About 3 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 getRegions has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        getRegions(exits: ExitInfo[]): RegionInfo[] {
            this.exitLookup = {};
            for (const exit of exits) {
                this.exitLookup[exit.id] = exit;
            }
    Severity: Minor
    Found in src/utils/nav-mesh.ts - About 3 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 isEnemyCloseToImportantStructures has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        isEnemyCloseToImportantStructures(): boolean {
            for (const structure of this.getImportantStructures()) {
                for (const userName in this.room.enemyCreeps) {
                    if (hivemind.relations.isAlly(userName)) continue;
    
    
    Severity: Minor
    Found in src/process/rooms/owned/defense.ts - About 3 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 addOptionsForTarget has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        addOptionsForTarget(info: PowerTargetRoom, roomName: string, sourceRoom: Room, options: PowerHarvesterSpawnOption[]) {
            // We're assigned to spawn creeps for this power gathering operation!
            const activePowerHarvesters = _.filter(Game.creepsByRole['harvester.power'] || [], (creep: Creep) => {
                if (creep.memory.isHealer) return false;
                if (creep.memory.sourceRoom !== sourceRoom.name) return false;
    Severity: Minor
    Found in src/spawn-role/harvester.power.ts - About 3 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 getRegions has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getRegions(exits: ExitInfo[]): RegionInfo[] {
            this.exitLookup = {};
            for (const exit of exits) {
                this.exitLookup[exit.id] = exit;
            }
    Severity: Major
    Found in src/utils/nav-mesh.ts - About 3 hrs to fix

      CombatManager has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class CombatManager {
          tileCache: Record<number, number>;
          tileCacheTime: number;
      
          hasRangedAttacked: boolean;
      Severity: Minor
      Found in src/creep/combat-manager.ts - About 3 hrs to fix

        Function calculateAdjacentRoomSafety has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            calculateAdjacentRoomSafety(options?: {safe?: string[]; unsafe?: string[]}): {directions: Record<string, boolean>; safeRooms: string[]} {
                return cache.inHeap('adjacentSafety:' + this.roomName, 100, () => {
                    if (!this.memory.exits) {
                        return {
                            directions: {
        Severity: Major
        Found in src/room-intel.ts - About 2 hrs to fix

          Function getOntoCachedPath has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Creep.prototype.getOntoCachedPath = function (this: Creep | PowerCreep) {
              const creep = this;
              const target = this.pos.findClosestByRange(this.getCachedPath(), {
                  filter: pos => {
                      // Try to move to a position on the path that is in the current room.
          Severity: Major
          Found in src/prototype/creep.movement.ts - About 2 hrs to fix

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

                addRepairOptions(creep: BuilderCreep, options: OrderOption[]) {
                    const targets = _.filter(
                        this.getAvailableRepairTargets(creep),
                        structure => structure.hits < structure.hitsMax
                            && !structure.needsDismantling()
            Severity: Minor
            Found in src/role/builder.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 ensureRemoteHarvestContainerIsBuilt has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                ensureRemoteHarvestContainerIsBuilt(creep: MineBuilderCreep) {
                    if (!(creep.operation instanceof RemoteMiningOperation)) return false;
                    if ((creep.store.energy || 0) === 0) return false;
            
                    const workParts = creep.getActiveBodyparts(WORK) || 0;
            Severity: Minor
            Found in src/role/builder.mines.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 depositResources has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                depositResources(creep: HarvesterCreep, source: Source | Mineral) {
                    const harvestPower = (source instanceof Source) ? HARVEST_POWER : HARVEST_MINERAL_POWER;
                    if (creep.store.getFreeCapacity() >= creep.getActiveBodyparts(WORK) * harvestPower) return;
            
                    const targetContainer = source.getNearbyContainer();
            Severity: Minor
            Found in src/role/harvester.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 getAlternateCreepPosition has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                getAlternateCreepPosition(creep: Creep | PowerCreep): RoomPosition | null {
                    if (!creep._requestedMoveArea && !creep._alternatePositions) return null;
            
                    let alternatePosition: RoomPosition;
                    const costMatrix = getCostMatrix(creep.room.name, {
            Severity: Minor
            Found in src/creep/traffic-manager.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 placeLabs has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                placeLabs() {
                    this.placementManager.startBuildingPlacement();
                    while (this.roomPlan.canPlaceMore('lab')) {
                        const nextPos = this.placementManager.getNextAvailableBuildSpot();
                        if (!nextPos) return 'failed';
            Severity: Minor
            Found in src/room/planner/variation-builder.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 getRampartGroups has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                getRampartGroups(): RoomPosition[][] {
                    const allRamparts = _.map(this.roomPlan.getPositions('rampart'), pos => ({
                        pos,
                        isUsed: false,
                    }));
            Severity: Minor
            Found in src/room/planner/variation-builder.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 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

            PlacementManager has 25 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class PlacementManager {
                public get ROAD_POSITION() {
                    return 1;
                }
            
            
            Severity: Minor
            Found in src/room/planner/placement-manager.ts - About 2 hrs to fix

              Function performGetRemoteBuilderEnergy has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  performGetRemoteBuilderEnergy() {
                      // @todo Switch to using priority list to determine where to get energy.
                      const creep = this.creep;
              
                      // Move to source room if necessary.
              Severity: Minor
              Found in src/role/builder.remote.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 getAvailableRepairTargets has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  getAvailableRepairTargets(creep: BuilderCreep): Array<Structure<BuildableStructureConstant>> {
                      const repairableStructureIds = cache.inHeap('repairStructures:' + creep.room.name, 50, () => {
                          const repairableStructures = _.filter(creep.room.structures, (structure: Structure<BuildableStructureConstant>) => {
                              if (structure.hits >= this.getStructureMaxHits(structure)) return false;
                              if (structure.needsDismantling()) return false;
              Severity: Minor
              Found in src/role/builder.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

              Severity
              Category
              Status
              Source
              Language