Mirroar/hivemind

View on GitHub
src/role/builder.ts

Summary

Maintainability
F
6 days
Test Coverage

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

/* global FIND_STRUCTURES FIND_MY_CONSTRUCTION_SITES STRUCTURE_SPAWN OK
STRUCTURE_RAMPART STRUCTURE_WALL STRUCTURE_ROAD STRUCTURE_CONTAINER WORK
UPGRADE_CONTROLLER_POWER RESOURCE_ENERGY */

import balancer from 'excess-energy-balancer';
Severity: Minor
Found in src/role/builder.ts - About 5 hrs to fix

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

        addRepairOptions(creep: BuilderCreep, options: OrderOption[]) {
            const targets = _.filter(
                this.getAvailableRepairTargets(creep),
                structure => structure.hits < structure.hitsMax
                    && !structure.needsDismantling()
    Severity: Minor
    Found in src/role/builder.ts - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    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 getAvailableRepairTargets has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        getAvailableRepairTargets(creep: BuilderCreep): Array<Structure<BuildableStructureConstant>> {
            const repairableStructureIds = cache.inHeap('repairStructures:' + creep.room.name, 50, () => {
                const repairableStructures = _.filter(creep.room.structures, (structure: Structure<BuildableStructureConstant>) => {
                    if (structure.hits >= this.getStructureMaxHits(structure)) return false;
                    if (structure.needsDismantling()) return false;
    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 performRepair has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        performRepair(creep: BuilderCreep): boolean {
            if (!creep.memory.order || !creep.memory.order.target || !Game.getObjectById(creep.memory.order.target)) {
                this.calculateBuilderTarget(creep);
            }
    
    
    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 run has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        run(creep: BuilderCreep) {
            if (creep.heapMemory.suicideSpawn) {
                this.performRecycle(creep);
                return;
            }
    Severity: Minor
    Found in src/role/builder.ts - About 1 hr to fix

      Function performRepair has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          performRepair(creep: BuilderCreep): boolean {
              if (!creep.memory.order || !creep.memory.order.target || !Game.getObjectById(creep.memory.order.target)) {
                  this.calculateBuilderTarget(creep);
              }
      
      
      Severity: Minor
      Found in src/role/builder.ts - About 1 hr to fix

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

            addRepairOptions(creep: BuilderCreep, options: OrderOption[]) {
                const targets = _.filter(
                    this.getAvailableRepairTargets(creep),
                    structure => structure.hits < structure.hitsMax
                        && !structure.needsDismantling()
        Severity: Minor
        Found in src/role/builder.ts - About 1 hr to fix

          Function modifyRepairDefensesOption has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              modifyRepairDefensesOption(creep: BuilderCreep, option, target: StructureWall | StructureRampart) {
                  option.priority--;
                  if (target.structureType === STRUCTURE_WALL) option.priority--;
          
                  // Walls and ramparts get repaired up to a certain health level.
          Severity: Minor
          Found in src/role/builder.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 performUpgrade has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              performUpgrade(creep: BuilderCreep) {
                  if (
                      creep.room.roomManager?.hasMisplacedSpawn()
                      || (creep.room.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL && !creep.room.controller?.safeMode)
                      || creep.room.find(FIND_MY_CONSTRUCTION_SITES).length > 0
          Severity: Minor
          Found in src/role/builder.ts - About 1 hr to fix

            Function modifyRepairDefensesOption has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                modifyRepairDefensesOption(creep: BuilderCreep, option, target: StructureWall | StructureRampart) {
                    option.priority--;
                    if (target.structureType === STRUCTURE_WALL) option.priority--;
            
                    // Walls and ramparts get repaired up to a certain health level.
            Severity: Minor
            Found in src/role/builder.ts - About 1 hr to fix

              Function getAvailableRepairTargets has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  getAvailableRepairTargets(creep: BuilderCreep): Array<Structure<BuildableStructureConstant>> {
                      const repairableStructureIds = cache.inHeap('repairStructures:' + creep.room.name, 50, () => {
                          const repairableStructures = _.filter(creep.room.structures, (structure: Structure<BuildableStructureConstant>) => {
                              if (structure.hits >= this.getStructureMaxHits(structure)) return false;
                              if (structure.needsDismantling()) return false;
              Severity: Minor
              Found in src/role/builder.ts - About 1 hr to fix

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

                        const repairableStructureIds = cache.inHeap('repairStructures:' + creep.room.name, 50, () => {
                            const repairableStructures = _.filter(creep.room.structures, (structure: Structure<BuildableStructureConstant>) => {
                                if (structure.hits >= this.getStructureMaxHits(structure)) return false;
                                if (structure.needsDismantling()) return false;
                
                
                Severity: Minor
                Found in src/role/builder.ts - About 1 hr to fix

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

                      getStructureMaxHits(structure: Structure<BuildableStructureConstant>): number {
                          if (structure.structureType === STRUCTURE_WALL || structure.structureType === STRUCTURE_RAMPART) {
                              // @todo Have a defcon system that determines how high ramparts
                              // should be at any given time.
                              let maxHealth = wallHealth[structure.room.controller.level];
                  Severity: Minor
                  Found in src/role/builder.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 getStructureMaxHits has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      getStructureMaxHits(structure: Structure<BuildableStructureConstant>): number {
                          if (structure.structureType === STRUCTURE_WALL || structure.structureType === STRUCTURE_RAMPART) {
                              // @todo Have a defcon system that determines how high ramparts
                              // should be at any given time.
                              let maxHealth = wallHealth[structure.room.controller.level];
                  Severity: Minor
                  Found in src/role/builder.ts - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (
                                    !this.performRepair(creep)
                                    && (creep.room.defense.getEnemyStrength() < ENEMY_STRENGTH_NORMAL || creep.room.controller?.safeMode)
                                ) {
                                    creep.room.memory.noBuilderNeeded = Game.time;
                    Severity: Major
                    Found in src/role/builder.ts - About 1 hr to fix

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

                          addBuildOptions(creep: BuilderCreep, options) {
                              const targets = creep.room.find(FIND_MY_CONSTRUCTION_SITES, {
                                  filter: site => this.isSafePosition(creep, site.pos),
                              });
                              for (const target of targets) {
                      Severity: Minor
                      Found in src/role/builder.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 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          repairNearby(creep: BuilderCreep) {
                              if (creep.store[RESOURCE_ENERGY] < creep.store.getCapacity() * 0.7 && creep.store[RESOURCE_ENERGY] > creep.store.getCapacity() * 0.3) return;
                              if (throttle(creep.heapMemory._tO)) return;
                      
                              const workParts = creep.getActiveBodyparts(WORK);
                      Severity: Minor
                      Found in src/role/builder.ts - About 45 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 true;
                      Severity: Major
                      Found in src/role/builder.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

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

                          Avoid too many return statements within this function.
                          Open

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

                            Avoid too many return statements within this function.
                            Open

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

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

                                  performUpgrade(creep: BuilderCreep) {
                                      if (
                                          creep.room.roomManager?.hasMisplacedSpawn()
                                          || (creep.room.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL && !creep.room.controller?.safeMode)
                                          || creep.room.find(FIND_MY_CONSTRUCTION_SITES).length > 0
                              Severity: Minor
                              Found in src/role/builder.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

                                  buildTarget(creep: BuilderCreep, target: ConstructionSite) {
                                      creep.whenInRange(3, target, () => {
                                          creep.build(target);
                                      });
                              
                              
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 2 hrs to fix
                              src/role/builder.ts on lines 559..568

                              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

                                  repairTarget(creep: BuilderCreep, target: Structure) {
                                      creep.whenInRange(3, target, () => {
                                          creep.repair(target);
                                      });
                              
                              
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 2 hrs to fix
                              src/role/builder.ts on lines 578..587

                              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 (controller.level == 8 && result == OK) {
                                              const amount = Math.min(creep.store[RESOURCE_ENERGY], creep.getActiveBodyparts(WORK) * UPGRADE_CONTROLLER_POWER);
                                              balancer.recordGplEnergy(amount);
                                          }
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/upgrader.ts on lines 102..105

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

                              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

                                      const isFunnelingElsewhere = creep.room.terminal && funnelManager.isFunneling() && !funnelManager.isFunnelingTo(creep.room.name) && creep.room.getEffectiveAvailableEnergy() < 100_000;
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 110..110

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

                              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

                                              const isFunnelingElsewhere = creep.room.terminal && funnelManager.isFunneling() && !funnelManager.isFunnelingTo(creep.room.name) && creep.room.getEffectiveAvailableEnergy() < 100_000;
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 176..176

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

                              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.memory.order || !creep.memory.order.target || !Game.getObjectById(creep.memory.order.target)) {
                                          return false;
                                      }
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 225..227

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

                              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.memory.order || !creep.memory.order.target || !Game.getObjectById(creep.memory.order.target)) {
                                              return false;
                                          }
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 214..216

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

                              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 (
                                              structure.structureType === STRUCTURE_WALL
                                              && structure.room.roomPlanner
                                              && structure.room.roomPlanner.isPlannedLocation(structure.pos, 'wall.quad')
                                          ) {
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 419..425

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

                              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 (
                                              structure.structureType === STRUCTURE_RAMPART
                                              && structure.room.roomPlanner
                                              && structure.room.roomPlanner.isPlannedLocation(structure.pos, 'rampart.ramp')
                                          ) {
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 411..417

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

                              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 (
                                                  structure.structureType === STRUCTURE_RAMPART
                                                  && creep.room.roomPlanner
                                                  && !creep.room.roomPlanner.isPlannedLocation(structure.pos, 'rampart')
                                              ) {
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 385..392

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

                              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 (
                                                  structure.structureType === STRUCTURE_WALL
                                                  && creep.room.roomPlanner
                                                  && !creep.room.roomPlanner.isPlannedLocation(structure.pos, 'wall')
                                              ) {
                              Severity: Major
                              Found in src/role/builder.ts and 1 other location - About 1 hr to fix
                              src/role/builder.ts on lines 376..383

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

                              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