Mirroar/hivemind

View on GitHub

Showing 899 of 1,362 total issues

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

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

        run() {
            if (!hivemind.settings.get('enableTradeManagement')) return;
    
            // Only trade if we have a terminal to trade with.
            if (_.size(_.filter(Game.myRooms, room => room.terminal)) === 0) return;
    Severity: Major
    Found in src/process/trade.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 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 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

        File main.ts has 301 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* global RawMemory */
        
        // Make sure game object prototypes are enhanced.
        import {ErrorMapper} from 'utils/ErrorMapper';
        
        
        Severity: Minor
        Found in src/main.ts - About 3 hrs to fix

          RoomManager has 27 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 3 hrs to fix

            Function performPickup has 78 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 performMilitaryAttack has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  performMilitaryAttack(creep: BrawlerCreep) {
                      if (creep.memory.order) {
                          // Attack ordered target first.
                          const target = Game.getObjectById<Creep | AnyOwnedStructure>(creep.memory.order.target);
              
              
              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 getBaseUpgraderAmount has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  getBaseUpgraderAmount(room: Room): number {
                      // Early on, builders will take care of upgrading once necessary
                      // structures have been built.
                      if (!room.storage && !room.terminal) return 0;
              
              
              Severity: Minor
              Found in src/spawn-role/upgrader.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 getRegions has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  getRegions(exits: ExitInfo[]): RegionInfo[] {
                      this.exitLookup = {};
                      for (const exit of exits) {
                          this.exitLookup[exit.id] = exit;
                      }
              Severity: Minor
              Found in src/utils/nav-mesh.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 addOptionsForTarget has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  addOptionsForTarget(info: PowerTargetRoom, roomName: string, sourceRoom: Room, options: PowerHarvesterSpawnOption[]) {
                      // We're assigned to spawn creeps for this power gathering operation!
                      const activePowerHarvesters = _.filter(Game.creepsByRole['harvester.power'] || [], (creep: Creep) => {
                          if (creep.memory.isHealer) return false;
                          if (creep.memory.sourceRoom !== sourceRoom.name) return false;
              Severity: Minor
              Found in src/spawn-role/harvester.power.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 isEnemyCloseToImportantStructures has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  isEnemyCloseToImportantStructures(): boolean {
                      for (const structure of this.getImportantStructures()) {
                          for (const userName in this.room.enemyCreeps) {
                              if (hivemind.relations.isAlly(userName)) continue;
              
              
              Severity: Minor
              Found in src/process/rooms/owned/defense.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 getRegions has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  getRegions(exits: ExitInfo[]): RegionInfo[] {
                      this.exitLookup = {};
                      for (const exit of exits) {
                          this.exitLookup[exit.id] = exit;
                      }
              Severity: Major
              Found in src/utils/nav-mesh.ts - About 3 hrs to fix

                Function calculateAdjacentRoomSafety has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    calculateAdjacentRoomSafety(options?: {safe?: string[]; unsafe?: string[]}): {directions: Record<string, boolean>; safeRooms: string[]} {
                        return cache.inHeap('adjacentSafety:' + this.roomName, 100, () => {
                            if (!this.memory.exits) {
                                return {
                                    directions: {
                Severity: Major
                Found in src/room-intel.ts - About 2 hrs to fix

                  Function getOntoCachedPath has 73 lines of code (exceeds 25 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: Major
                  Found in src/prototype/creep.movement.ts - About 2 hrs to fix

                    Function ensureRemoteHarvestContainerIsBuilt has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        ensureRemoteHarvestContainerIsBuilt(creep: MineBuilderCreep) {
                            if (!(creep.operation instanceof RemoteMiningOperation)) return false;
                            if ((creep.store.energy || 0) === 0) return false;
                    
                            const workParts = creep.getActiveBodyparts(WORK) || 0;
                    Severity: Minor
                    Found in src/role/builder.mines.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 addRepairOptions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        addRepairOptions(creep: BuilderCreep, options: OrderOption[]) {
                            const targets = _.filter(
                                this.getAvailableRepairTargets(creep),
                                structure => structure.hits < structure.hitsMax
                                    && !structure.needsDismantling()
                    Severity: Minor
                    Found in src/role/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

                    Severity
                    Category
                    Status
                    Source
                    Language