Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

Function run has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    run() {
        const manager = container.get('TradeRouteManager');
        let routes = manager.getAvailableTransportRoutes();
        let best = utilities.getBestOption(routes);

Severity: Minor
Found in src/process/resources.ts - About 5 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

File scout.ts has 398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global RoomPosition OBSERVER_RANGE SOURCE_ENERGY_CAPACITY */

import Process from 'process/process';
import hivemind from 'hivemind';
import interShard from 'intershard';
Severity: Minor
Found in src/process/strategy/scout.ts - About 5 hrs to fix

    RoomIntel has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class RoomIntel {
        roomName: string;
        memory: RoomIntelMemory;
        newStatus: Record<string, boolean>;
    
    
    Severity: Minor
    Found in src/room-intel.ts - About 5 hrs to fix

      Function buildRoadOnCachedPath has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          buildRoadOnCachedPath(creep: MineBuilderCreep) {
              // Don't try to build roads in rooms owned by other players.
              if (creep.room.controller && creep.room.controller.owner && !creep.room.isMine()) return false;
      
              const workParts = creep.getActiveBodyparts(WORK);
      Severity: Minor
      Found in src/role/builder.mines.ts - About 5 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 addObjectEnergySourceOptions has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          addObjectEnergySourceOptions(options: TransporterSourceOrderOption[], findConstant: FIND_RUINS | FIND_TOMBSTONES | FIND_DROPPED_RESOURCES, optionType: 'resource' | 'tombstone', storagePriority: number) {
              const creep = this.creep;
      
              // Get storage location, since that is a low priority source for transporters.
              const storagePosition = creep.room.getStorageLocation();
      Severity: Minor
      Found in src/role/transporter.ts - About 5 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

      File builder.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* global FIND_STRUCTURES FIND_MY_CONSTRUCTION_SITES STRUCTURE_SPAWN OK
      STRUCTURE_RAMPART STRUCTURE_WALL STRUCTURE_ROAD STRUCTURE_CONTAINER WORK
      UPGRADE_CONTROLLER_POWER RESOURCE_ENERGY */
      
      import balancer from 'excess-energy-balancer';
      Severity: Minor
      Found in src/role/builder.ts - About 5 hrs to fix

        File room.resources.ts has 386 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* global Room RoomPosition RESOURCE_ENERGY LOOK_RESOURCES
        RESOURCE_POWER STRUCTURE_LAB RESOURCES_ALL */
        
        import cache from 'utils/cache';
        import container from 'utils/container';
        Severity: Minor
        Found in src/prototype/room.resources.ts - About 5 hrs to fix

          File remote-mining.ts has 381 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* global RoomPosition SOURCE_ENERGY_CAPACITY CARRY_CAPACITY
          SOURCE_ENERGY_NEUTRAL_CAPACITY ENERGY_REGEN_TIME CONTROLLER_RESERVE_MAX
          HARVEST_POWER LOOK_STRUCTURES STRUCTURE_CONTAINER */
          
          import cache from 'utils/cache';
          Severity: Minor
          Found in src/operation/remote-mining.ts - About 5 hrs to fix

            Function addContainerEnergySourceOptions has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                private addContainerEnergySourceOptions(options: ContainerSourceTask[], context: ResourceSourceContext) {
                    const creep = context.creep;
                    if (context.resourceType && context.resourceType !== RESOURCE_ENERGY) return;
            
                    // Look for energy in Containers.
            Severity: Minor
            Found in src/dispatcher/resource-source/container.ts - About 5 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 addLabResourceOptions has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                addLabResourceOptions(options: LabSourceTask[], context: ResourceSourceContext) {
                    const room = this.room;
                    const currentReaction = room.memory.currentReaction;
                    if (!room.memory.canPerformReactions) return;
            
            
            Severity: Minor
            Found in src/dispatcher/resource-source/lab.ts - About 5 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

            File hauler.relay.ts has 376 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* global FIND_DROPPED_RESOURCES RESOURCE_ENERGY OK LOOK_CONSTRUCTION_SITES
            ERR_NO_PATH ERR_NOT_IN_RANGE STRUCTURE_CONTAINER STRUCTURE_ROAD
            FIND_MY_CONSTRUCTION_SITES LOOK_STRUCTURES MAX_CONSTRUCTION_SITES */
            
            // @todo Collect energy if it's lying on the path.
            Severity: Minor
            Found in src/role/hauler.relay.ts - About 5 hrs to fix

              File mincut.ts has 373 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* global TERRAIN_MASK_WALL */
              
              /**
               * Code for calculating the minCut in a room.
               * Based on code written by Saruss and adapted by Chobobobo.
              Severity: Minor
              Found in src/utils/mincut.ts - About 4 hrs to fix

                Function goTo has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                Creep.prototype.goTo = function (this: Creep | PowerCreep, target: RoomObject | RoomPosition, options: GoToOptions) {
                    if (!target) return false;
                    if (!options) options = {};
                
                    container.get('TrafficManager').setMoving(this);
                Severity: Minor
                Found in src/prototype/creep.movement.ts - About 4 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 moveUsingNavMesh has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                Creep.prototype.moveUsingNavMesh = function (this: Creep | PowerCreep, targetPos, options) {
                    if (!hivemind.segmentMemory.isReady()) return OK;
                
                    if (!options) options = {};
                
                
                Severity: Minor
                Found in src/prototype/creep.movement.ts - About 4 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

                File combat-manager.ts has 367 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import cache from 'utils/cache';
                import hivemind from 'hivemind';
                import utilities from 'utilities';
                import {getResourcesIn} from 'utils/store';
                import {handleMapArea} from 'utils/map';
                Severity: Minor
                Found in src/creep/combat-manager.ts - About 4 hrs to fix

                  Function addConnectingPathsForRegion has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                  Open

                      addConnectingPathsForRegion(region: RegionInfo, paths: Record<number, Record<number, number>>, roomName: string, costMatrix: CostMatrix) {
                          const centerXR = region.center % 50;
                          const centerYR = Math.floor(region.center / 50);
                  
                          for (const exitId of region.exits) {
                  Severity: Minor
                  Found in src/utils/nav-mesh.ts - About 4 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 addHarvesterOptionForPosition has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                  Open

                      addHarvesterOptionForPosition(room: Room, position: RoomPosition, options: RemoteMiningSpawnOption[]) {
                          const targetPos = encodePosition(position);
                          const operation = Game.operationsByType.mining['mine:' + position.roomName];
                  
                          // Don't spawn if enemies are in the room.
                  Severity: Minor
                  Found in src/spawn-role/remote-mining.ts - About 4 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

                  RoomVariationBuilder has 36 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export default class RoomVariationBuilder extends RoomVariationBuilderBase {
                      exitCenters: ExitCoords;
                      roomCenter: RoomPosition;
                      roomCenterEntrances: RoomPosition[];
                      safetyMatrix: CostMatrix;
                  Severity: Minor
                  Found in src/room/planner/variation-builder.ts - About 4 hrs to fix

                    Function run has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                    Open

                        run(creep: PowerHaulerCreep) {
                            if (!creep.memory.isReturning && (creep.store.getFreeCapacity() === 0 || (creep.store.power || 0) > creep.store.getCapacity() / 10)) {
                                // Return home.
                                creep.memory.isReturning = true;
                                return;
                    Severity: Minor
                    Found in src/role/power/hauler.ts - About 4 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 followCachedPath has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Creep.prototype.followCachedPath = function (this: Creep | PowerCreep) {
                        drawCreepMovement(this);
                    
                        container.get('TrafficManager').setMoving(this);
                        this.heapMemory._moveBlocked = false;
                    Severity: Minor
                    Found in src/prototype/creep.movement.ts - About 4 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