Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

Function calculateExpansionScore has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    calculateExpansionScore(roomName: string) {
        const result: ExpansionScore = {
            score: 0,
            reasons: {},
            addScore(amount: number, reason: string) {
Severity: Major
Found in src/process/strategy/scout.ts - About 3 hrs to fix

    File intershard.ts has 318 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import cache from 'utils/cache';
    import hivemind from 'hivemind';
    import interShard from 'intershard';
    import NavMesh from 'utils/nav-mesh';
    import Process from 'process/process';
    Severity: Minor
    Found in src/process/strategy/intershard.ts - About 3 hrs to fix

      Function addClearingTerminalResourceOptions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          addClearingTerminalResourceOptions(options: StorageSourceTask[], context: ResourceSourceContext) {
              const storage = this.room.storage;
              const terminal = this.room.terminal;
      
              // Clear out overfull terminal.
      Severity: Minor
      Found in src/dispatcher/resource-source/storage.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 addMilitaryAttackOptions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          addMilitaryAttackOptions(creep: BrawlerCreep, options: MilitaryTargetOption[]) {
              const enemies = creep.room.find(FIND_HOSTILE_CREEPS);
              const targetPosition = decodePosition(creep.memory.target);
      
              if (enemies && enemies.length > 0) {
      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 deleteTilesLeadingToDeadEnds has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          deleteTilesLeadingToDeadEnds(roomName: string, minCut: Array<{x: number; y: number}>) {
              // Get terrain and set all cut-tiles as unwalkable.
              const roomTerrain = generateRoomTerrainArray(roomName);
              for (const tile of minCut) {
                  roomTerrain[tile.x][tile.y] = UNWALKABLE;
      Severity: Minor
      Found in src/utils/mincut.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 generateRoomTerrainArray has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      function generateRoomTerrainArray(roomName: string, bounds?: MinCutRect) {
          if (!bounds) bounds = {x1: 0, y1: 0, x2: 49, y2: 49};
      
          // Create two dimensional array of room tiles.
          const roomArray = Array.from({length: 50}).fill(0).map(() => Array.from({length: 50}).fill(UNWALKABLE)) as number[][];
      Severity: Minor
      Found in src/utils/mincut.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 placeRamparts has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          placeRamparts(): StepResult {
              // Make sure the controller can't directly be reached by enemies.
              const roomIntel = getRoomIntel(this.roomName);
              const safety = roomIntel.calculateAdjacentRoomSafety();
      
      
      Severity: Minor
      Found in src/room/planner/variation-builder.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 runTick has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          runTick() {
              this.useMemoryFromHeap();
      
              hivemind.segmentMemory.manage();
      
      
      Severity: Major
      Found in src/main.ts - About 3 hrs to fix

        Function manageBlockingCreeps has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        Creep.prototype.manageBlockingCreeps = function (this: Creep | PowerCreep) {
            const path = this.getCachedPath();
            if (typeof this.memory.cachedPath.position === 'undefined' || this.memory.cachedPath.position === null) {
                for (const pos of path) {
                    // @todo Look for the _furthest_ position that is in range 1.
        Severity: Minor
        Found in src/prototype/creep.movement.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 render has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        PathFinder.CostMatrix.prototype.render = function (this: CostMatrix, roomName?: string, asVisual?: boolean): string {
            const terrain = roomName && Game.map.getRoomTerrain(roomName);
            const visual = roomName && asVisual && Game.rooms[roomName]?.visual;
        
            let output = '<table style="display: inline-block">';
        Severity: Minor
        Found in src/prototype/cost-matrix.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 ensureBoostsHaveLabAssigned has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            private ensureBoostsHaveLabAssigned(boosts: Partial<Record<ResourceConstant, number>>) {
                const roomLabs = this.getAllLabs();
        
                for (const resourceType in boosts) {
                    const assignedLab = _.find(roomLabs, lab => this.memory.labs[lab.id] === resourceType);
        Severity: Minor
        Found in src/boost-manager.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 run has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            run() {
                const operationName = 'room:' + this.room.name;
                let operation = Game.operationsByType.room[operationName];
                if (!operation) {
                    operation = new RoomOperation(operationName);
        Severity: Major
        Found in src/process/rooms/owned.ts - About 3 hrs to fix

          File brawler.ts has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* global RoomPosition MOVE ATTACK HEAL RANGED_ATTACK ATTACK_POWER
          RANGED_ATTACK_POWER HEAL_POWER RESOURCE_ENERGY */
          
          import BodyBuilder from 'creep/body-builder';
          import cache from 'utils/cache';
          Severity: Minor
          Found in src/spawn-role/brawler.ts - About 3 hrs to fix

            OperatorRole has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class OperatorRole extends Role {
                creep: PowerCreep;
            
                /**
                 * Makes a power creep behave like an operator.
            Severity: Minor
            Found in src/role/power-creep/operator.ts - About 3 hrs to fix

              Function performPickup has 82 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  performPickup(creep: RelayHaulerCreep) {
                      creep.say('p0');
                      const sourcePosition = decodePosition(creep.memory.source);
                      if (!sourcePosition) {
                          creep.say('newtar');
              Severity: Major
              Found in src/role/hauler.relay.ts - About 3 hrs to fix

                Function performRemoteHarvest has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                    performRemoteHarvest(creep: RemoteHarvesterCreep) {
                        if (creep.pos.roomName !== creep.operation.getRoom()) return;
                
                        // Check if a container nearby is in need of repairs, since we can handle
                        // it with less intents than haulers do.
                Severity: Minor
                Found in src/role/harvester.remote.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 attackMilitaryTarget has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                    attackMilitaryTarget(creep: BrawlerCreep, target: Creep | AnyStructure) {
                        if (target instanceof StructureController) {
                            if (target.owner && creep.attackController(target) === OK) {
                                return true;
                            }
                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 getStoredEnergy has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                Room.prototype.getStoredEnergy = function (this: Room) {
                    return cache.inObject(this, 'storedEnergy', 1, () => {
                        let total = this.getCurrentResourceAmount(RESOURCE_ENERGY);
                
                        // Add energy on storage location (pre storage).
                Severity: Minor
                Found in src/prototype/room.resources.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 getDamageCapacity has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                Creep.prototype.getDamageCapacity = function (this: Creep, range) {
                    // @todo Cache for one tick?
                    let total = 0;
                    if (range > 3) return total;
                
                
                Severity: Minor
                Found in src/prototype/creep.military.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 addClaimerSpawnOptions has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                    addClaimerSpawnOptions(room: Room, options: RemoteMiningSpawnOption[]) {
                        if (options.length > 0) return;
                
                        // Only spawn claimers if they can have 2 or more claim parts.
                        // @todo We could even do it with 1 part if the controller has multiple
                Severity: Minor
                Found in src/spawn-role/remote-mining.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

                Severity
                Category
                Status
                Source
                Language