Mirroar/hivemind

View on GitHub

Showing 900 of 1,365 total issues

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

    addIntershardSpawnOptions(options: ReclaimSpawnOption[]) {
        const interShardMemory = interShard.getLocalMemory();
        for (const shardName in (interShardMemory.portals || {})) {
            const shardMemory = interShard.getRemoteMemory(shardName);
            if (!shardMemory?.info?.rooms?.reclaimable) continue;
Severity: Minor
Found in src/spawn-role/reclaim.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

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

    constructor() {
        this.allies = [];
        this.enemies = [];

        if (localRelations?.allies) {
Severity: Minor
Found in src/relations.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

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

    getReclaimSpawnOptions(room: Room, options: BrawlerSpawnOption[]) {
        if (room.getEffectiveAvailableEnergy() < 10_000) return;

        for (const targetRoom of Game.myRooms) {
            if (room.name === targetRoom.name) continue;
Severity: Minor
Found in src/spawn-role/brawler.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

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

    generateScoutTargets() {
        const roomList = Memory.strategy.roomList || {};

        const openList = this.getScoutOrigins();
        const closedList: Record<string, boolean> = {};
Severity: Minor
Found in src/process/strategy/scout.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

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

    addIntershardSpawnOptionsFor(request: {name: string; safe: boolean; rcl: number; portalRoom?: string}, shardName: string, options: ReclaimSpawnOption[]) {
        if (!request.portalRoom) return;
        if (request.rcl < 4) return;
        if (!request.safe) return;

Severity: Minor
Found in src/spawn-role/reclaim.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

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

    drawExpansionStatus() {
        if (!Memory.strategy.expand) return;

        // Visualize failed expansion attempts.
        for (const attempt of Memory.strategy.expand.failedExpansions || []) {
Severity: Minor
Found in src/process/map-visuals.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

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

    registerCaravan(id: string) {
        if (!Memory.strategy) Memory.strategy = {};
        if (!Memory.strategy.caravans) Memory.strategy.caravans = {};

        const creeps = _.sortBy(_.filter(this.room.enemyCreeps[SYSTEM_USERNAME], c => c.name.startsWith(id)), c => c.name);
Severity: Minor
Found in src/process/rooms/highway.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

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

    needsSpawning(room: Room, squad: Squad): SquadUnitType | null {
        const neededUnits: SquadUnitType[] = [];
        for (const unitType in squad.memory.composition) {
            if (!availableUnitTypes.includes(unitType as SquadUnitType)) continue;

Severity: Minor
Found in src/spawn-role/squad.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

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

    private getAllRequestedBoosts(): Partial<Record<ResourceConstant, number>> {
        const boosts = {};
        for (const creepName in this.memory.creeps) {
            if (Game.creeps[creepName]?.room?.name !== this.room.name) continue;

Severity: Minor
Found in src/boost-manager.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

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

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

    visualize() {
        const visual = new RoomVisual(this.roomName);
        for (const type in this.positionsByType) {
            if (!structureSymbols[type]) continue;

Severity: Minor
Found in src/room/planner/room-plan.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

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

    isRoomRecovering(): boolean {
        if ((this.room.controller.safeMode ?? 0) > 5000) return false;
        if (this.room.needsReclaiming()) return true;

        if (this.structuresByType[STRUCTURE_SPAWN] && this.structuresByType[STRUCTURE_SPAWN].length > 0) return false;
Severity: Minor
Found in src/room/room-manager.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

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

    placeRoadNetwork(): StepResult {
        // Find paths from each exit towards the room center for making roads.
        for (const dir of _.keys(this.exitCenters)) {
            for (const pos of this.exitCenters[dir]) {
                const exitRoads = this.placementManager.findAccessRoad(pos, this.roomCenterEntrances);
Severity: Minor
Found in src/room/planner/variation-builder.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

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

    isPositionAccessible(pos: RoomPosition, noTunnels?: boolean) {
        // We don't care about cost, just about possibility.
        const result = PathFinder.search(pos, this.originEntrances, {
            roomCallback: () => this.buildingMatrix,
            maxRooms: 1,
Severity: Minor
Found in src/room/planner/placement-manager.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

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

    placeHarvestBayStructures(): StepResult {
        const roomIntel = getRoomIntel(this.roomName);
        for (const source of roomIntel.getSourcePositions()) {
            const shouldAddSpawn = this.variationInfo.sourcesWithSpawn.includes(source.id);
            const harvestPosition = this.sourceInfo[source.id].harvestPosition;
Severity: Minor
Found in src/room/planner/variation-builder.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

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

    findAccessRoad(from: RoomPosition, to: RoomPosition | RoomPosition[], breakExtensions?: boolean): RoomPosition[] {
        const result = PathFinder.search(from, to, {
            roomCallback: () => {
                if (!breakExtensions) return this.buildingMatrix;

Severity: Minor
Found in src/room/planner/placement-manager.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

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

    scoreExtractorPositions(positions: RoomPosition[]): ScoredExtractorPosition[] {
        const result: ScoredExtractorPosition[] = [];

        for (const position of positions) {
            const mineral = position.lookFor(LOOK_MINERALS)[0];
Severity: Minor
Found in src/room/room-manager.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

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

    buildPlannedStructures(locationType: string, structureType: StructureConstant, filterCallback?: (pos: RoomPosition) => boolean): boolean {
        let canBuildMore = true;
        for (const pos of this.roomPlanner.getLocations(locationType)) {
            if (filterCallback && !filterCallback(pos)) continue;
            if (this.tryBuild(pos, structureType)) continue;
Severity: Minor
Found in src/room/room-manager.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

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

    getLocalMemory(): ShardMemory {
        if (typeof InterShardMemory === 'undefined') {
            // Create mock intershard memory object.
            if (!Memory.interShardReplacement) Memory.interShardReplacement = {};

Severity: Minor
Found in src/intershard.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

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

    checkWallIntegrity(minHits?: number) {
        // @todo make this consistent with defense manager.
        if (!minHits) minHits = hivemind.settings.get('minWallIntegrity');
        const maxHealth = hivemind.settings.get('maxWallHealth');

Severity: Minor
Found in src/room/room-manager.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

Severity
Category
Status
Source
Language