Mirroar/hivemind

View on GitHub

Showing 900 of 1,365 total issues

Function manageTowers has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    manageTowers() {
        const towers = _.filter(this.room.myStructuresByType[STRUCTURE_TOWER], s => s.energy > 0);

        if (towers.length === 0) return;

Severity: Minor
Found in src/process/rooms/owned/defense.ts - About 6 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 checkClaimPath has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    checkClaimPath() {
        const info = this.memory.currentTarget;
        if (!info) return;

        const room = Game.rooms[info.roomName];
Severity: Minor
Found in src/process/strategy/expand.ts - About 6 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 operator.ts has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global RoomPosition OK POWER_INFO PWR_GENERATE_OPS PWR_REGEN_SOURCE
PWR_OPERATE_STORAGE PWR_OPERATE_SPAWN RESOURCE_OPS STORAGE_CAPACITY
STRUCTURE_SPAWN PWR_OPERATE_EXTENSION RESOURCE_ENERGY
PWR_REGEN_MINERAL POWER_CREEP_LIFE_TIME PWR_OPERATE_TOWER */

Severity: Minor
Found in src/role/power-creep/operator.ts - About 6 hrs to fix

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

    /* global MOVE CLAIM BODYPART_COST CONTROLLER_RESERVE_MAX RESOURCE_ENERGY */
    
    import BodyBuilder from 'creep/body-builder';
    import hivemind from 'hivemind';
    import settings from 'settings-manager';
    Severity: Minor
    Found in src/spawn-role/remote-mining.ts - About 6 hrs to fix

      Function calculateRoomPath has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.calculateRoomPath = function (targetRoom: string, options) {
          const roomName = this.name;
      
          if (!options) options = {};
      
      
      Severity: Minor
      Found in src/prototype/room.pathfinding.ts - About 6 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 getResourceLevelCutoffs has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.getResourceLevelCutoffs = function (this: Room, resourceType: ResourceConstant): ResourceLevelCuttoffs {
          if (resourceType === RESOURCE_ENERGY) {
              // Defending rooms need energy to defend.
              if (this.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL) return [1_000_000, 100_000, 50_000];
      
      
      Severity: Minor
      Found in src/prototype/room.resources.ts - About 6 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 trade.ts has 413 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* global RESOURCES_ALL RESOURCE_ENERGY RESOURCE_POWER OK RESOURCE_OPS
      ORDER_BUY ORDER_SELL PIXEL STORAGE_CAPACITY INTERSHARD_RESOURCES
      REACTION_TIME */
      
      import cache from 'utils/cache';
      Severity: Minor
      Found in src/process/trade.ts - About 5 hrs to fix

        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

            File builder.ts has 395 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

              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 remote-mining.ts has 379 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 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

                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

                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 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

                  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 cleanup has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                  Open

                      cleanup() {
                          // Periodically clean creep memory.
                          if (Game.time % 16 === 7) {
                              for (const name in Memory.creeps) {
                                  if (!Game.creeps[name]) {
                  Severity: Minor
                  Found in src/main.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