Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

Function totalTime has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        const totalTime = timeCall('operation:' + operationName, () => {
            hivemind.runSubProcess('rooms_roomplanner', () => {
                // RoomPlanner has its own 100 tick throttling, so we runLogic every tick.
                if (this.room.roomPlanner) this.room.roomPlanner.runLogic();
            });
Severity: Major
Found in src/process/rooms/owned.ts - About 2 hrs to fix

    Function performMilitaryMove has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        performMilitaryMove(creep: BrawlerCreep) {
            if (creep.isPartOfTrain() && this.performTrainMove(creep) !== OK) return;
    
            if (creep.memory.fillWithEnergy) {
                if (creep.room.isMine() && creep.store.getFreeCapacity() > 0) {
    Severity: Major
    Found in src/role/brawler.ts - About 2 hrs to fix

      Function saveExpiringRamparts has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          saveExpiringRamparts(minHits: number): boolean {
              if (!this.creep.memory.repairTarget) {
                  // Make sure ramparts don't break.
                  const ramparts = _.filter(
                      this.creep.room.structuresByType[STRUCTURE_RAMPART],
      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 performUpgrade has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          performUpgrade(creep: UpgraderCreep, allowRefilling: boolean) {
              // Upgrade controller.
              const controller = creep.room.controller;
              const distance = creep.pos.getRangeTo(controller);
              const isOnlyUpgrader = creep.memory.role === 'upgrader' && _.size(creep.room.creepsByRole.upgrader) === 1;
      Severity: Minor
      Found in src/role/upgrader.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 findHostiles has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          findHostiles() {
              const parts = {};
              let lastSeen = this.room.memory.enemies ? this.room.memory.enemies.lastSeen : 0;
              let expires = null;
              let safe = true;
      Severity: Minor
      Found in src/process/rooms/intel.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 removeMisplacedSpawn has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          removeMisplacedSpawn(roomSpawns: StructureSpawn[]) {
              for (const spawn of roomSpawns) {
                  if (this.roomPlanner.isPlannedLocation(spawn.pos, 'spawn')) continue;
      
                  // Only destroy spawn if there are enough resources and builders available.
      Severity: Minor
      Found in src/room/room-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 pruneWalls has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          pruneWalls(walls: RoomPosition[]) {
              const roomIntel = getRoomIntel(this.roomName);
              const safety = roomIntel.calculateAdjacentRoomSafety();
              const roomCenter = _.first(this.roomPlan.getPositions('center'));
              this.safetyMatrix = new PathFinder.CostMatrix();
      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 placeDecorativeWalls has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          placeDecorativeWalls(): StepResult {
              const patternHeight = decorativeWallPattern.length;
              const patternWidth = decorativeWallPattern[0].length;
      
              for (let x = 1; x < 49; x++) {
      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 performRemoteHarvest has 60 lines of code (exceeds 25 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: Major
      Found in src/role/harvester.remote.ts - About 2 hrs to fix

        Function performGetRemoteBuilderEnergy has 59 lines of code (exceeds 25 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: Major
        Found in src/role/builder.remote.ts - About 2 hrs to fix

          Function followCachedPath has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Creep.prototype.followCachedPath = function (this: Creep | PowerCreep) {
              drawCreepMovement(this);
          
              container.get('TrafficManager').setMoving(this);
              this.heapMemory._moveBlocked = false;
          Severity: Major
          Found in src/prototype/creep.movement.ts - About 2 hrs to fix

            NavMesh has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class NavMesh {
                memory: NavMemory;
                terrain: RoomTerrain;
                costMatrix: CostMatrix;
                exitLookup: Record<number, ExitInfo>;
            Severity: Minor
            Found in src/utils/nav-mesh.ts - About 2 hrs to fix

              BoostManager has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export default class BoostManager {
                  memory: BoostManagerMemory;
                  room: Room;
              
                  public constructor(room: Room) {
              Severity: Minor
              Found in src/boost-manager.ts - About 2 hrs to fix

                TradeProcess has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default class TradeProcess extends Process {
                    availableCredits: number;
                
                    /**
                     * Buys and sells resources on the global market.
                Severity: Minor
                Found in src/process/trade.ts - About 2 hrs to fix

                  Function addMilitaryAttackOptions has 58 lines of code (exceeds 25 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: Major
                  Found in src/role/brawler.ts - About 2 hrs to fix

                    Function run has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        run() {
                            // @todo Add throttle like with remote harvesting.
                            const memory = Memory.strategy.power;
                            this.mesh = new NavMesh();
                    
                    
                    Severity: Major
                    Found in src/process/strategy/power.ts - About 2 hrs to fix

                      Function depositResources has 57 lines of code (exceeds 25 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: Major
                      Found in src/role/harvester.ts - About 2 hrs to fix

                        Function joinTrain has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        Creep.prototype.joinTrain = function (this: Creep) {
                            const segments = this.getTrainParts();
                        
                            let canMoveBack = true;
                            for (let i = 1; i < segments.length; i++) {
                        Severity: Minor
                        Found in src/prototype/creep.train.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 getNearbyTargets has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private getNearbyTargets(creep: Creep): AttackTarget[] {
                                const availableTargets: AttackTarget[] = [];
                                const maxRange = this.getMaxAttackRange(creep);
                        
                                for (const enemyName in creep.room.enemyCreeps) {
                        Severity: Minor
                        Found in src/creep/combat-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 trySpawnCreep has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            trySpawnCreep(room: Room, spawn: StructureSpawn, option): boolean {
                                const role = this.roles[option.role];
                                const body = role.getCreepBody(room, option);
                        
                                if (!body || body.length === 0) return false;
                        Severity: Minor
                        Found in src/spawn-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

                        Severity
                        Category
                        Status
                        Source
                        Language