Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

File creep.movement.ts has 733 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global Creep PowerCreep RoomVisual RoomPosition LOOK_CREEPS OK
LOOK_CONSTRUCTION_SITES ERR_NO_PATH LOOK_STRUCTURES LOOK_POWER_CREEPS */

import cache from 'utils/cache';
import container from 'utils/container';
Severity: Major
Found in src/prototype/creep.movement.ts - About 1 day to fix

    Function findPath has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
    Open

        findPath(startPos: RoomPosition, endPos: RoomPosition, options?: {maxPathLength?: number; allowDanger?: boolean; maxCpu?: number}): {
            path?: RoomPosition[];
            length?: number;
            incomplete: boolean;
        } {
    Severity: Minor
    Found in src/utils/nav-mesh.ts - About 1 day 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 room-intel.ts has 652 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* global PathFinder Room RoomPosition
    STRUCTURE_KEEPER_LAIR STRUCTURE_CONTROLLER FIND_SOURCES
    TERRAIN_MASK_WALL TERRAIN_MASK_SWAMP POWER_BANK_DECAY STRUCTURE_PORTAL
    STRUCTURE_POWER_BANK FIND_MY_CONSTRUCTION_SITES STRUCTURE_STORAGE
    STRUCTURE_TERMINAL FIND_RUINS STRUCTURE_INVADER_CORE EFFECT_COLLAPSE_TIMER */
    Severity: Major
    Found in src/room-intel.ts - About 1 day to fix

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

      import hivemind from 'hivemind';
      import minCut from 'utils/mincut';
      import PlaceTowersStep from 'room/planner/step/place-towers';
      import RoomVariationBuilderBase from 'room/planner/variation-builder-base';
      import settings from 'settings-manager';
      Severity: Major
      Found in src/room/planner/variation-builder.ts - About 1 day to fix

        File nav-mesh.ts has 618 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* global PathFinder Room RoomPosition LEFT RIGHT TOP BOTTOM
        TERRAIN_MASK_WALL STRUCTURE_KEEPER_LAIR */
        
        import cache from 'utils/cache';
        import hivemind from 'hivemind';
        Severity: Major
        Found in src/utils/nav-mesh.ts - About 1 day to fix

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

          /* global Structure STRUCTURE_ROAD STRUCTURE_WALL STRUCTURE_SPAWN
          STRUCTURE_CONTAINER STRUCTURE_TOWER STRUCTURE_EXTENSION STRUCTURE_RAMPART
          STRUCTURE_TERMINAL STRUCTURE_STORAGE STRUCTURE_EXTRACTOR STRUCTURE_LAB
          STRUCTURE_NUKER STRUCTURE_POWER_SPAWN STRUCTURE_OBSERVER LOOK_STRUCTURES
          LOOK_CONSTRUCTION_SITES CONSTRUCTION_COST CREEP_LIFE_TIME MAX_CONSTRUCTION_SITES
          Severity: Major
          Found in src/room/room-manager.ts - About 1 day to fix

            Function addEnemyRangeScore has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
            Open

                private addEnemyRangeScore(creep: Creep, enemyCreeps: Creep[], positions: ScoredPosition[]) {
                    const maxRange = this.getMaxAttackRange(creep);
                    const isRangedCreep = maxRange > 1;
            
                    // @todo Corner positions are beneficial when we're fleeing, and
            Severity: Minor
            Found in src/creep/combat-manager.ts - About 1 day 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 transporter.ts has 541 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* global PathFinder Room RoomPosition FIND_DROPPED_RESOURCES
            STRUCTURE_CONTAINER RESOURCE_POWER RESOURCE_GHODIUM STRUCTURE_LAB REACTIONS
            STRUCTURE_EXTENSION STRUCTURE_SPAWN STRUCTURE_TOWER STRUCTURE_NUKER ERR_NO_PATH
            STRUCTURE_POWER_SPAWN TERRAIN_MASK_WALL LOOK_STRUCTURES RESOURCE_ENERGY
            LOOK_CONSTRUCTION_SITES OK ORDER_SELL FIND_TOMBSTONES FIND_RUINS */
            Severity: Major
            Found in src/role/transporter.ts - About 1 day to fix

              Function calculateExpansionScore has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
              Open

                  calculateExpansionScore(roomName: string) {
                      const result: ExpansionScore = {
                          score: 0,
                          reasons: {},
                          addScore(amount: number, reason: string) {
              Severity: Minor
              Found in src/process/strategy/scout.ts - About 7 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 createGraph has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
              Open

                  createGraph(roomName: string, rect: MinCutRect[], bounds: MinCutRect) {
                      const roomTerrain = generateRoomTerrainArray(roomName, bounds);
              
                      // For all Rectangles, set edges as source (to protect area) and area as unused
                      // Check bounds
              Severity: Minor
              Found in src/utils/mincut.ts - About 7 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 expand.ts has 467 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* global PathFinder Room RoomPosition CREEP_LIFE_TIME FIND_MY_CREEPS
              TERRAIN_MASK_WALL STRUCTURE_ROAD FIND_CONSTRUCTION_SITES STRUCTURE_RAMPART */
              
              import cache from 'utils/cache';
              import Process from 'process/process';
              Severity: Minor
              Found in src/process/strategy/expand.ts - About 7 hrs to fix

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

                /* global PathFinder RoomPosition StructureController ATTACK SYSTEM_USERNAME
                STRUCTURE_CONTROLLER STRUCTURE_STORAGE STRUCTURE_SPAWN STRUCTURE_TOWER HEAL
                LOOK_STRUCTURES FIND_STRUCTURES FIND_MY_CREEPS CREEP_LIFE_TIME CLAIM
                FIND_HOSTILE_STRUCTURES OK STRUCTURE_TERMINAL STRUCTURE_INVADER_CORE
                ERR_BUSY ERR_NOT_OWNER ERR_TIRED RANGED_ATTACK FIND_HOSTILE_CREEPS */
                Severity: Minor
                Found in src/role/brawler.ts - About 7 hrs to fix

                  Function getOntoCachedPath has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Creep.prototype.getOntoCachedPath = function (this: Creep | PowerCreep) {
                      const creep = this;
                      const target = this.pos.findClosestByRange(this.getCachedPath(), {
                          filter: pos => {
                              // Try to move to a position on the path that is in the current room.
                  Severity: Minor
                  Found in src/prototype/creep.movement.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 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

                  File trade.ts has 439 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 6 hrs to fix

                    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

                    RoomManager has 45 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    export default class RoomManager {
                        room: Room;
                        roomPlanner: RoomPlanner;
                        memory: RoomManagerMemory;
                        roomConstructionSites: ConstructionSite[];
                    Severity: Minor
                    Found in src/room/room-manager.ts - About 6 hrs to fix

                      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

                        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

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

                        /* global MOVE CLAIM BODYPART_COST CONTROLLER_RESERVE_MAX RESOURCE_ENERGY */
                        
                        import BodyBuilder, {MOVEMENT_MODE_PLAINS, MOVEMENT_MODE_ROAD} 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
                          Severity
                          Category
                          Status
                          Source
                          Language