Mirroar/hivemind

View on GitHub
src/role/hauler.relay.ts

Summary

Maintainability
F
5 days
Test Coverage

File hauler.relay.ts has 359 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 4 hrs to fix

    Function performPickup has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        performPickup(creep: RelayHaulerCreep) {
            creep.say('p0');
            const sourcePosition = decodePosition(creep.memory.source);
            if (!sourcePosition) {
                creep.say('newtar');
    Severity: Minor
    Found in src/role/hauler.relay.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 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 performDeliver has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          performDeliver(creep: RelayHaulerCreep) {
              const sourceRoom = creep.memory.sourceRoom;
              if (!Game.rooms[sourceRoom]) return;
      
              if (this.performRelay(creep)) return;
      Severity: Minor
      Found in src/role/hauler.relay.ts - About 1 hr 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 getNearbyEnergyTarget has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getNearbyEnergyTarget(creep: RelayHaulerCreep) {
              if (creep.heapMemory.energyPickupTarget) {
                  const target = Game.getObjectById(creep.heapMemory.energyPickupTarget);
      
                  if (target && target.pos.roomName === creep.pos.roomName && ((target instanceof Resource) || target.store.getUsedCapacity(RESOURCE_ENERGY) >= 20)) {
      Severity: Minor
      Found in src/role/hauler.relay.ts - About 1 hr to fix

        Function scoreHarvestPosition has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            scoreHarvestPosition(creep: RelayHaulerCreep, position: RoomPosition) {
                const targetPos = encodePosition(position);
                const operation = Game.operationsByType.mining['mine:' + position.roomName];
                if (!operation) return {position, energy: -1000};
        
        
        Severity: Minor
        Found in src/role/hauler.relay.ts - About 1 hr to fix

          Function performDeliver has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              performDeliver(creep: RelayHaulerCreep) {
                  const sourceRoom = creep.memory.sourceRoom;
                  if (!Game.rooms[sourceRoom]) return;
          
                  if (this.performRelay(creep)) return;
          Severity: Minor
          Found in src/role/hauler.relay.ts - About 1 hr to fix

            Function getNearbyEnergyTarget has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                getNearbyEnergyTarget(creep: RelayHaulerCreep) {
                    if (creep.heapMemory.energyPickupTarget) {
                        const target = Game.getObjectById(creep.heapMemory.energyPickupTarget);
            
                        if (target && target.pos.roomName === creep.pos.roomName && ((target instanceof Resource) || target.store.getUsedCapacity(RESOURCE_ENERGY) >= 20)) {
            Severity: Minor
            Found in src/role/hauler.relay.ts - About 1 hr 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 storeResources has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                storeResources(creep: RelayHaulerCreep, target?: AnyStoreStructure) {
                    this.transferEnergyToNearbyTargets(creep);
            
                    if (!creep.room.storage && !creep.room.terminal) {
                        if (!creep.heapMemory.order || !creep.room.destinationDispatcher.validateTask(creep.heapMemory.order, {creep})) {
            Severity: Minor
            Found in src/role/hauler.relay.ts - About 35 mins 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

            Avoid too many return statements within this function.
            Open

                        return;
            Severity: Major
            Found in src/role/hauler.relay.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return null;
              Severity: Major
              Found in src/role/hauler.relay.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return;
                Severity: Major
                Found in src/role/hauler.relay.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              if (!targetPosition) return;
                  Severity: Major
                  Found in src/role/hauler.relay.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return;
                    Severity: Major
                    Found in src/role/hauler.relay.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return;
                      Severity: Major
                      Found in src/role/hauler.relay.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return ruin[0];
                        Severity: Major
                        Found in src/role/hauler.relay.ts - About 30 mins to fix

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

                              run(creep: RelayHaulerCreep) {
                                  if (!hivemind.segmentMemory.isReady()) return;
                          
                                  // @todo If empty, but there's no operation, return home and wait (or suicide).
                          
                          
                          Severity: Minor
                          Found in src/role/hauler.relay.ts - About 25 mins 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

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              getPath(creep: RelayHaulerCreep): RoomPosition[] | null {
                                  if (!creep.operation) return null;
                          
                                  const paths = creep.operation.getPaths();
                                  if (!paths[creep.memory.source] || !paths[creep.memory.source].accessible) return null;
                          Severity: Major
                          Found in src/role/hauler.relay.ts and 1 other location - About 4 hrs to fix
                          src/role/builder.mines.ts on lines 135..142

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 121.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              getSource(creep: RelayHaulerCreep): Source {
                                  const sourcePosition = decodePosition(creep.memory.source);
                                  return creep.room.find(FIND_SOURCES, {
                                      filter: source => source.pos.x === sourcePosition.x && source.pos.y === sourcePosition.y,
                                  })[0];
                          Severity: Major
                          Found in src/role/hauler.relay.ts and 1 other location - About 3 hrs to fix
                          src/role/builder.mines.ts on lines 263..268

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 108.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  const queuedHaulerCapacity = _.sum(
                                      _.filter(Game.creepsByRole['hauler.relay'], (creep: RelayHaulerCreep) => creep.memory.source === targetPos && !creep.memory.delivering),
                                      (creep: Creep) => creep.store.getFreeCapacity(RESOURCE_ENERGY),
                                  );
                          Severity: Major
                          Found in src/role/hauler.relay.ts and 1 other location - About 2 hrs to fix
                          src/role/hauler.relay.ts on lines 113..116

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 91.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  const queuedBuilderCapacity = _.sum(
                                      _.filter(Game.creepsByRole['builder.mines'], (creep: MineBuilderCreep) => creep.memory.source === targetPos && !creep.memory.returning),
                                      (creep: Creep) => creep.store.getFreeCapacity(RESOURCE_ENERGY),
                                  );
                          Severity: Major
                          Found in src/role/hauler.relay.ts and 1 other location - About 2 hrs to fix
                          src/role/hauler.relay.ts on lines 109..112

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 91.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  if (bestPosition?.position) {
                                      creep.memory.source = encodePosition(bestPosition.position);
                                      creep.memory.operation = 'mine:' + bestPosition.position.roomName;
                                  }
                          Severity: Major
                          Found in src/role/hauler.relay.ts and 1 other location - About 1 hr to fix
                          src/role/builder.mines.ts on lines 108..111

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 61.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Identical blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  if (
                                      creep.pos.roomName === sourcePosition.roomName
                                      && this.getSource(creep)?.isDangerous()
                                      && creep.pos.getRangeTo(sourcePosition) <= 10
                                  ) {
                          Severity: Major
                          Found in src/role/hauler.relay.ts and 1 other location - About 1 hr to fix
                          src/role/builder.mines.ts on lines 210..225

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 57.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  const resources = creep.pos.findInRange(FIND_DROPPED_RESOURCES, 3, {
                                      filter: resource => resource.resourceType === RESOURCE_ENERGY && resource.amount >= 20,
                                  });
                          Severity: Minor
                          Found in src/role/hauler.relay.ts and 1 other location - About 55 mins to fix
                          src/role/builder.mines.ts on lines 300..302

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 53.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  const tombstone = creep.pos.findInRange(FIND_TOMBSTONES, 3, {
                                      filter: tombstone => tombstone.store.getUsedCapacity(RESOURCE_ENERGY) >= 20,
                                  });
                          Severity: Minor
                          Found in src/role/hauler.relay.ts and 1 other location - About 35 mins to fix
                          src/role/hauler.relay.ts on lines 490..492

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  const ruin = creep.pos.findInRange(FIND_RUINS, 3, {
                                      filter: ruin => ruin.store.getUsedCapacity(RESOURCE_ENERGY) >= 20,
                                  });
                          Severity: Minor
                          Found in src/role/hauler.relay.ts and 1 other location - About 35 mins to fix
                          src/role/hauler.relay.ts on lines 481..483

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 47.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                                  if (tombstone.length > 0) {
                                      creep.heapMemory.energyPickupTarget = tombstone[0].id;
                                      return tombstone[0];
                                  }
                          Severity: Minor
                          Found in src/role/hauler.relay.ts and 2 other locations - About 30 mins to fix
                          src/role/hauler.relay.ts on lines 476..479
                          src/role/hauler.relay.ts on lines 494..497

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 45.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                                  if (ruin.length > 0) {
                                      creep.heapMemory.energyPickupTarget = ruin[0].id;
                                      return ruin[0];
                                  }
                          Severity: Minor
                          Found in src/role/hauler.relay.ts and 2 other locations - About 30 mins to fix
                          src/role/hauler.relay.ts on lines 476..479
                          src/role/hauler.relay.ts on lines 485..488

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 45.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 3 locations. Consider refactoring.
                          Open

                                  if (resources.length > 0) {
                                      creep.heapMemory.energyPickupTarget = resources[0].id;
                                      return resources[0];
                                  }
                          Severity: Minor
                          Found in src/role/hauler.relay.ts and 2 other locations - About 30 mins to fix
                          src/role/hauler.relay.ts on lines 485..488
                          src/role/hauler.relay.ts on lines 494..497

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 45.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          There are no issues that match your filters.

                          Category
                          Status