Mirroar/hivemind

View on GitHub
src/role/builder.mines.ts

Summary

Maintainability
F
5 days
Test Coverage

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

File builder.mines.ts has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global FIND_DROPPED_RESOURCES RESOURCE_ENERGY OK
ERR_NO_PATH ERR_NOT_IN_RANGE FIND_STRUCTURES STRUCTURE_CONTAINER STRUCTURE_ROAD
FIND_MY_CONSTRUCTION_SITES LOOK_STRUCTURES MAX_CONSTRUCTION_SITES
LOOK_CONSTRUCTION_SITES */

Severity: Minor
Found in src/role/builder.mines.ts - About 3 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 performReturnHome has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        performReturnHome(creep: MineBuilderCreep) {
            // Refill at container if we emptied ourselves too much repairing it.
            const container = creep.operation?.getContainer(creep.memory.source);
            if (container && container.pos.roomName === creep.pos.roomName && creep.pos.getRangeTo(container) < 10
                    && creep.store.getUsedCapacity() < creep.store.getCapacity() * 0.5
    Severity: Minor
    Found in src/role/builder.mines.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 performGoToSource has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        performGoToSource(creep: MineBuilderCreep) {
            const sourcePosition = decodePosition(creep.memory.source);
    
            if (
                creep.pos.roomName === sourcePosition.roomName
    Severity: Minor
    Found in src/role/builder.mines.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 performGoToSource has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        performGoToSource(creep: MineBuilderCreep) {
            const sourcePosition = decodePosition(creep.memory.source);
    
            if (
                creep.pos.roomName === sourcePosition.roomName
    Severity: Minor
    Found in src/role/builder.mines.ts - About 1 hr to fix

      Function performReturnHome has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          performReturnHome(creep: MineBuilderCreep) {
              // Refill at container if we emptied ourselves too much repairing it.
              const container = creep.operation?.getContainer(creep.memory.source);
              if (container && container.pos.roomName === creep.pos.roomName && creep.pos.getRangeTo(container) < 10
                      && creep.store.getUsedCapacity() < creep.store.getCapacity() * 0.5
      Severity: Minor
      Found in src/role/builder.mines.ts - About 1 hr to fix

        Function buildRoadOnCachedPath has 35 lines of code (exceeds 25 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 1 hr to fix

          Function pickupNearbyEnergy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              pickupNearbyEnergy(creep: MineBuilderCreep) {
                  if (creep.store.getFreeCapacity(RESOURCE_ENERGY) < 20) return false;
          
                  // @todo Allow hauler to pick up other resources as well, but respect that
                  // when returning.
          Severity: Minor
          Found in src/role/builder.mines.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 pickupNearbyEnergy has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              pickupNearbyEnergy(creep: MineBuilderCreep) {
                  if (creep.store.getFreeCapacity(RESOURCE_ENERGY) < 20) return false;
          
                  // @todo Allow hauler to pick up other resources as well, but respect that
                  // when returning.
          Severity: Minor
          Found in src/role/builder.mines.ts - About 1 hr to fix

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

                performBuildRoad(creep: MineBuilderCreep) {
                    const workParts = creep.getActiveBodyparts(WORK);
                    if (workParts === 0) return false;
            
                    if ((creep.store[RESOURCE_ENERGY] || 0) === 0) return false;
            Severity: Minor
            Found in src/role/builder.mines.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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                run(creep: MineBuilderCreep) {
                    // @todo Take from haulers when next to them. Also take from harvesters when building container so they don't have to.
                    if (!hivemind.segmentMemory.isReady()) return;
            
                    if (creep.heapMemory.suicideSpawn) {
            Severity: Minor
            Found in src/role/builder.mines.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 ensureRemoteHarvestContainerIsBuilt has 26 lines of code (exceeds 25 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 1 hr to fix

              Function buildNearby has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  buildNearby(creep: MineBuilderCreep): boolean {
                      const workParts = creep.getActiveBodyparts(WORK);
                      const needsBuilding = creep.pos.findClosestByRange(FIND_MY_CONSTRUCTION_SITES, {
                          filter: site => site.structureType === STRUCTURE_CONTAINER || site.structureType === STRUCTURE_ROAD,
                      });
              Severity: Minor
              Found in src/role/builder.mines.ts - About 55 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

              Function repairNearby has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  repairNearby(creep: MineBuilderCreep): boolean {
                      const workParts = creep.getActiveBodyparts(WORK);
                      const needsRepair = creep.pos.findClosestByRange(FIND_STRUCTURES, {
                          filter: structure => (structure.structureType === STRUCTURE_ROAD || structure.structureType === STRUCTURE_CONTAINER) && structure.hits < structure.hitsMax - (workParts * 100),
                      });
              Severity: Minor
              Found in src/role/builder.mines.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 false;
              Severity: Major
              Found in src/role/builder.mines.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                if (this.actionTaken) return true;
                Severity: Major
                Found in src/role/builder.mines.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          if (!containerPosition || containerPosition.roomName !== creep.pos.roomName) return false;
                  Severity: Major
                  Found in src/role/builder.mines.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return false;
                    Severity: Major
                    Found in src/role/builder.mines.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return true;
                      Severity: Major
                      Found in src/role/builder.mines.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                if (this.ensureRemoteHarvestContainerIsBuilt(creep)) return true;
                        Severity: Major
                        Found in src/role/builder.mines.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  if (this.buildNearby(creep)) return true;
                          Severity: Major
                          Found in src/role/builder.mines.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return false;
                            Severity: Major
                            Found in src/role/builder.mines.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return false;
                              Severity: Major
                              Found in src/role/builder.mines.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        else if (this.repairNearby(creep)) return true;
                                Severity: Major
                                Found in src/role/builder.mines.ts - About 30 mins to fix

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

                                      getPath(creep: MineBuilderCreep): 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/builder.mines.ts and 1 other location - About 4 hrs to fix
                                  src/role/hauler.relay.ts on lines 143..150

                                  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: MineBuilderCreep): 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/builder.mines.ts and 1 other location - About 3 hrs to fix
                                  src/role/hauler.relay.ts on lines 408..413

                                  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

                                  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/builder.mines.ts and 1 other location - About 1 hr to fix
                                  src/role/hauler.relay.ts on lines 87..90

                                  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/builder.mines.ts and 1 other location - About 1 hr to fix
                                  src/role/hauler.relay.ts on lines 311..326

                                  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 >= 100,
                                              });
                                  Severity: Minor
                                  Found in src/role/builder.mines.ts and 1 other location - About 55 mins to fix
                                  src/role/hauler.relay.ts on lines 472..474

                                  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

                                                  if (creep.repair(container) === OK) {
                                                      creep.operation.addResourceCost(workParts, RESOURCE_ENERGY);
                                                      this.actionTaken = true;
                                                  }
                                  Severity: Minor
                                  Found in src/role/builder.mines.ts and 1 other location - About 40 mins to fix
                                  src/role/builder.mines.ts on lines 427..430

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

                                  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

                                              if (creep.repair(needsRepair) === OK) {
                                                  creep.operation.addResourceCost(workParts, RESOURCE_ENERGY);
                                                  this.actionTaken = true;
                                              }
                                  Severity: Minor
                                  Found in src/role/builder.mines.ts and 1 other location - About 40 mins to fix
                                  src/role/builder.mines.ts on lines 466..469

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

                                  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 hasHarvester = _.some(Game.creepsByRole['harvester.remote'], (c: RemoteHarvesterCreep) => c.memory.source === targetPos);
                                  Severity: Minor
                                  Found in src/role/builder.mines.ts and 1 other location - About 35 mins to fix
                                  src/role/builder.mines.ts on lines 121..121

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

                                  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 hasBuilder = _.some(Game.creepsByRole['builder.mines'], (c: MineBuilderCreep) => c.memory.source === targetPos);
                                  Severity: Minor
                                  Found in src/role/builder.mines.ts and 1 other location - About 35 mins to fix
                                  src/role/builder.mines.ts on lines 124..124

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

                                  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