Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

Avoid too many return statements within this function.
Open

        return true;
Severity: Major
Found in src/room/room-manager.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return true;
    Severity: Major
    Found in src/room/planner/variation-builder-base.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              if (this.room.isEvacuating()) return;
      Severity: Major
      Found in src/room/room-manager.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                if (!this.canCreateConstructionSites()) return;
        Severity: Major
        Found in src/room/room-manager.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  if (!this.checkWallIntegrity()) return;
          Severity: Major
          Found in src/room/room-manager.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return true;
            Severity: Major
            Found in src/room/room-manager.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return;
              Severity: Major
              Found in src/process/trade.ts - About 30 mins to fix

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

                    getMissingComponents(): Partial<Record<FactoryComponentConstant, number>> | null {
                        const requestedResources = this.getRequestedComponents();
                        const result: Partial<Record<FactoryComponentConstant, number>> = {};
                        let hasNeed = false;
                
                
                Severity: Minor
                Found in src/factory-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 gatherPortalIntel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    gatherPortalIntel(portals: StructurePortal[]) {
                        delete this.memory.portals;
                
                        const targetRooms: string[] = [];
                        for (const portal of portals || []) {
                Severity: Minor
                Found in src/room-intel.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 performUpgrade has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    performUpgrade(creep: BuilderCreep) {
                        if (
                            creep.room.roomManager?.hasMisplacedSpawn()
                            || (creep.room.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL && !creep.room.controller?.safeMode)
                            || creep.room.find(FIND_MY_CONSTRUCTION_SITES).length > 0
                Severity: Minor
                Found in src/role/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 isValid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    isValid(task: TaskType, context: ResourceDestinationContext) {
                        const structure = Game.getObjectById(task.target);
                        if (!structure) return false;
                        if (!structure.isOperational()) return false;
                        if (context.creep.memory.singleRoom && structure.pos.roomName !== context.creep.memory.singleRoom) return false;
                Severity: Minor
                Found in src/dispatcher/resource-destination/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 gatherControllerIntel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    gatherControllerIntel(room: Room) {
                        this.memory.owner = null;
                        this.memory.rcl = 0;
                        this.memory.ticksToDowngrade = 0;
                        this.memory.hasController = typeof room.controller !== 'undefined';
                Severity: Minor
                Found in src/room-intel.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 addResourcesForSaleDestination has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    addResourcesForSaleDestination(options: TerminalDestinationTask[], context: ResourceDestinationContext) {
                        const terminal = this.room.terminal;
                
                        const roomSellOrders = _.filter(Game.market.orders, order => order.roomName === this.room.name && order.type === ORDER_SELL);
                        for (const order of roomSellOrders) {
                Severity: Minor
                Found in src/dispatcher/resource-destination/terminal.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 usePower has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    usePower() {
                        const order = this.creep.memory.order as OperatorUsePowerOrder;
                        const power = order.power;
                        const powerInfo = POWER_INFO[power];
                        const range = 'range' in powerInfo ? powerInfo.range : 1;
                Severity: Minor
                Found in src/role/power-creep/operator.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 getAdjacentRampartPositions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    getAdjacentRampartPositions(creep: GuardianCreep): RoomPosition[] {
                        const closestRamparts = _.filter(
                            creep.room.myStructuresByType[STRUCTURE_RAMPART],
                            s => {
                                if (s.pos.getRangeTo(creep.pos) !== 1) return false;
                Severity: Minor
                Found in src/role/guardian.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 performDeliver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    performDeliver(creep: DepositHarvesterCreep) {
                        const origin = creep.memory.origin;
                        if (!Game.rooms[origin] || !Game.rooms[origin].isMine()) {
                            // @todo Choose a new room close by and deliver.
                            return;
                Severity: Minor
                Found in src/role/harvester.deposit.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 isOscillating has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    isOscillating(creep: ScoutCreep) {
                        if (!creep.heapMemory.roomHistory) creep.heapMemory.roomHistory = [];
                        const history = creep.heapMemory.roomHistory;
                
                        if (history.length === 0 || history[history.length - 1] !== creep.pos.roomName) history.push(creep.pos.roomName);
                Severity: Minor
                Found in src/role/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 mayCurrentOrderBeInterrupted has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    mayCurrentOrderBeInterrupted(): boolean {
                        const order = this.creep.memory.order;
                        if (!order) return true;
                        if (order.type === 'performRenew') return false;
                        if (!('target' in order)) return true;
                Severity: Minor
                Found in src/role/power-creep/operator.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 migrateData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    migrateData() {
                        // Move room intel into segment memory.
                        if (!this.memory.intelMigrated) {
                            if (!this.segmentMemory.isReady()) return true;
                
                
                Severity: Minor
                Found in src/hivemind.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 getNextBodyPart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private getNextBodyPart(partCounts: PartCounts): BodyPartConstant {
                        const currentWeights = this.normalizeWeights(partCounts);
                
                        let fallbackPart: BodyPartConstant = null;
                        for (const part of (_.keys(this.weights) as BodyPartConstant[])) {
                Severity: Minor
                Found in src/creep/body-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

                Severity
                Category
                Status
                Source
                Language