Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

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

Creep.prototype.transferAny = function (this: Creep, target: Structure): ScreepsReturnCode {
    for (const resourceType of getResourcesIn(this.store)) {
        if (target.structureType === STRUCTURE_LINK && resourceType !== RESOURCE_ENERGY) continue;
        if (this.store[resourceType] > 0) {
            return this.transfer(target, resourceType);
Severity: Minor
Found in src/prototype/creep.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 generateTileCache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private generateTileCache(pos: RoomPosition, encodedPos: string) {
        if (this.tileCacheTime !== Game.time) {
            this.tileCache = {};
            this.tileCacheTime = Game.time;
        }
Severity: Minor
Found in src/creep/combat-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 couldWinFightAgainst has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public couldWinFightAgainst(creep: Creep, otherCreep: Creep): boolean {
        if (
            (
                creep.getActiveBodyparts(RANGED_ATTACK) > 0
                || (creep.getActiveBodyparts(ATTACK) > 0 && otherCreep.getActiveBodyparts(RANGED_ATTACK) === 0)
Severity: Minor
Found in src/creep/combat-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 needsDismantler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    needsDismantler(sourceLocation?: string): boolean {
        if (!hivemind.segmentMemory.isReady()) return false;
        if (sourceLocation) return this.getDismantlePositions(sourceLocation).length > 0;

        for (const pos of this.getSourcePositions()) {
Severity: Minor
Found in src/operation/remote-mining.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 calculatePath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Creep.prototype.calculatePath = function (this: Creep | PowerCreep, target: RoomPosition, options?: GoToOptions): RoomPosition[] {
    if (!options) options = {};

    // @todo Properly type this.
    const pfOptions: any = {};
Severity: Minor
Found in src/prototype/creep.movement.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 getCurrentMineralAmount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Room.prototype.getCurrentMineralAmount = function (this: Room) {
    return cache.inObject(this, 'storedMinerals', 1, () => {
        let total = 0;

        for (const resourceType of RESOURCES_ALL) {
Severity: Minor
Found in src/prototype/room.resources.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 moveToRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Creep.prototype.moveToRoom = function (this: Creep | PowerCreep, roomName, allowDanger) {
    // Make sure we recalculate path if target changes.
    if (this.heapMemory._mtrTarget !== roomName) {
        delete this.heapMemory._mtrNextRoom;
        this.heapMemory._mtrTarget = roomName;
Severity: Minor
Found in src/prototype/creep.movement.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    run(creep: RelayHaulerCreep) {
        if (!hivemind.segmentMemory.isReady()) return;

        // @todo If empty, but there's no operation, return home and wait (or suicide).

Severity: Minor
Found in src/role/hauler.relay.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 isBayExtension has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

StructureExtension.prototype.isBayExtension = function () {
    if (!this.bayChecked) {
        this.bayChecked = true;
        this.bay = null;

Severity: Minor
Found in src/prototype/structure.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 manage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    manage() {
        if (!Memory.segmented) {
            Memory.segmented = {
                // Force saving data immediately so we don't have wrongly formatted
                // old data in segment 0.
Severity: Minor
Found in src/utils/segmented-memory.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 addInitialHarvester has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    addInitialHarvester(source: Source, options: HarvesterSpawnOption[]) {
        // Spawn new harvester before previous harvester dies.
        const spawns = _.filter(Game.spawns, spawn => spawn.room.name === source.room.name);
        const minSpawnDistance = _.min(_.map(spawns, spawn => spawn.pos.getRangeTo(source.pos)));
        const activeHarvesters = _.filter(source.harvesters, creep => creep.spawning || creep.ticksToLive > creep.body.length * CREEP_SPAWN_TIME + minSpawnDistance);
Severity: Minor
Found in src/spawn-role/harvester.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 getMaxWorkParts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    getMaxWorkParts(source: Source): number {
        let numberOfParts = source.energyCapacity / ENERGY_REGEN_TIME / 2;

        _.each(source.effects, effect => {
            if (effect.effect === PWR_REGEN_SOURCE) {
Severity: Minor
Found in src/spawn-role/harvester.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 getUpgraderAmount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    getUpgraderAmount(room: Room): number {
        const maxUpgraders = this.getBaseUpgraderAmount(room);

        if (maxUpgraders === 0) {
            // Even if no upgraders are needed, at least create one when the controller is getting close to being downgraded.
Severity: Minor
Found in src/spawn-role/upgrader.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 consumer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static get consumer(): SourceMapConsumer {
        if (this._consumer == null) {
            let sourceMap;
            try {
                sourceMap = require('main.map.js');
Severity: Minor
Found in src/utils/ErrorMapper.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 getCreepBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    getCreepBody(room: Room, option: UpgraderSpawnOption): BodyPartConstant[] {
        const hasEasyEnergyAccess = room.memory.controllerContainer || room.memory.controllerLink;

        return (new BodyBuilder())
            .setWeights({[CARRY]: 1, [WORK]: hasEasyEnergyAccess ? 10 : 1})
Severity: Minor
Found in src/spawn-role/upgrader.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 throttle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function throttle(offset: number, minBucket?: number, maxBucket?: number) {
    initThrottleMemory();

    if (!offset) offset = 0;
    if (typeof minBucket !== 'number') minBucket = Memory.throttleInfo.bucket.critical;
Severity: Minor
Found in src/utils/throttle.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 addEmergencyRepairSpawnOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    addEmergencyRepairSpawnOptions(room: Room, options: RoomDefenseSpawnOption[]) {
        if (room.controller.level < 4) return;
        if (!room.memory.enemies || room.memory.enemies.safe) return;
        if (room.getEffectiveAvailableEnergy() < 10_000) return;

Severity: Minor
Found in src/spawn-role/room-defense.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(channel: string, roomName?: string) {
        this.channel = channel;
        this.channelName = ('          ' + this.channel).slice(-10);
        this.color = channels.default.color;
        this.roomName = roomName;
Severity: Minor
Found in src/utils/debug.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

Severity
Category
Status
Source
Language