Mirroar/hivemind

View on GitHub

Showing 886 of 1,349 total issues

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

    run(creep: BuilderCreep) {
        if (creep.heapMemory.suicideSpawn) {
            this.performRecycle(creep);
            return;
        }
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

Function addContainerResourceOptions has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    addContainerResourceOptions(options: TransporterSourceOrderOption[]) {
        const room = this.creep.room;
        // We need a decent place to store these resources.
        if (!room.terminal && !room.storage) return;

Severity: Minor
Found in src/role/transporter.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 getPathFor has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    getPathFor(sourcePosition: RoomPosition): RoomPosition[] | null {
        if (!hivemind.segmentMemory.isReady()) return null;

        const key = 'remotePath:' + encodePosition(sourcePosition);
        if (!hivemind.segmentMemory.has(key)) {
Severity: Minor
Found in src/empire/remote-path-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 run has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    run(): StepResult {
        // @todo Make sure tower access roads are always behind ramparts!
        let towerCount = 0;

        const positions = this.findTowerPositions();
Severity: Minor
Found in src/room/planner/step/place-towers.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 addLabResourceOptions has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    addLabResourceOptions(options: LabSourceTask[], context: ResourceSourceContext) {
        const room = this.room;
        const currentReaction = room.memory.currentReaction;
        if (!room.memory.canPerformReactions) return;

Severity: Major
Found in src/dispatcher/resource-source/lab.ts - About 2 hrs to fix

    Function checkClaimPath has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        checkClaimPath() {
            const info = this.memory.currentTarget;
            if (!info) return;
    
            const room = Game.rooms[info.roomName];
    Severity: Major
    Found in src/process/strategy/expand.ts - About 2 hrs to fix

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

        RemoteMiningSpawnRole has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class RemoteMiningSpawnRole extends SpawnRole {
            /**
             * Adds claimer spawn options for the given room.
             *
             * @param {Room} room
        Severity: Minor
        Found in src/spawn-role/remote-mining.ts - About 2 hrs to fix

          Function calculateRoomPath has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Room.prototype.calculateRoomPath = function (targetRoom: string, options) {
              const roomName = this.name;
          
              if (!options) options = {};
          
          
          Severity: Major
          Found in src/prototype/room.pathfinding.ts - About 2 hrs to fix

            Function moveUsingNavMesh has 65 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Creep.prototype.moveUsingNavMesh = function (this: Creep | PowerCreep, targetPos, options) {
                if (!hivemind.segmentMemory.isReady()) return OK;
            
                if (!options) options = {};
            
            
            Severity: Major
            Found in src/prototype/creep.movement.ts - About 2 hrs to fix

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

                  run(creep: RemoteBuilderCreep) {
                      this.creep = creep;
              
                      if (creep.memory.interShardPortal) {
                          const targetPos = decodePosition(creep.memory.interShardPortal);
              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 performOperationDismantle has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  performOperationDismantle(creep: DismantlerCreep): boolean {
                      if (!creep.operation) return false;
                      if (!(creep.operation instanceof RemoteMiningOperation)) return false;
              
                      if (!creep.heapMemory.finishedPositions) creep.heapMemory.finishedPositions = [];
              Severity: Minor
              Found in src/role/dismantler.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 performSkSlaughter has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  performSkSlaughter(creep: SkKillerCreep) {
                      if (creep.pos.roomName !== creep.operation.getRoom()) return;
                      creep.memory.singleRoom = creep.operation.getRoom();
              
                      const sourceKeepers = [];
              Severity: Minor
              Found in src/role/sk-killer.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 getRemoteDefenseSpawnOptions has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  getRemoteDefenseSpawnOptions(room: Room, options: BrawlerSpawnOption[]) {
                      if (room.getEffectiveAvailableEnergy() < 5_000) return;
              
                      const harvestPositions: RoomPosition[] = room.getRemoteHarvestSourcePositions();
                      for (const pos of harvestPositions) {
              Severity: Minor
              Found in src/spawn-role/brawler.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 handleRequests has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  handleRequests() {
                      for (const request of simpleAllies.allySegmentData?.requests?.funnel ?? []) {
                          if (!Memory.requests.trade[RESOURCE_ENERGY]) {
                              Memory.requests.trade[RESOURCE_ENERGY] = {};
                          }
              Severity: Minor
              Found in src/process/allies.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 manageStructures has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  manageStructures() {
                      if (_.size(Game.spawns) === 1 && _.sample(Game.spawns).room.name === this.room.name && this.room.controller.level < 4) {
                          // In our first room, getting more extensions is pretty important for
                          // spawning bigger creeps asap.
                          this.manageExtensions();
              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 instaBuyResources has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  instaBuyResources(resourceType: TradeResource, rooms?: Record<string, RoomResourceState>, force?: boolean) {
                      // Find room with lowest amount of this resource.
                      const roomName = isIntershardResource(resourceType) ? null : this.getRoomLowestOn(resourceType, rooms);
                      if (!roomName && !isIntershardResource(resourceType)) return;
              
              
              Severity: Minor
              Found in src/process/trade.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

              File cost-matrix.ts has 272 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import cache from 'utils/cache';
              import hivemind from 'hivemind';
              import {encodePosition} from 'utils/serialization';
              import {ENEMY_STRENGTH_NONE} from 'room-defense';
              import {getRoomIntel} from 'room-intel';
              Severity: Minor
              Found in src/utils/cost-matrix.ts - About 2 hrs to fix

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

                    run() {
                        const manager = container.get('TradeRouteManager');
                        let routes = manager.getAvailableTransportRoutes();
                        let best = utilities.getBestOption(routes);
                
                
                Severity: Major
                Found in src/process/resources.ts - About 2 hrs to fix

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

                      performGetResources(sourceCallback?: () => void) {
                          const creep = this.creep;
                          if (!sourceCallback) {
                              sourceCallback = () => {
                                  this.calculateSource();
                  Severity: Major
                  Found in src/role/transporter.ts - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language