Mirroar/hivemind

View on GitHub
src/room/room-manager.ts

Summary

Maintainability
F
1 wk
Test Coverage

File room-manager.ts has 552 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global Structure STRUCTURE_ROAD STRUCTURE_WALL STRUCTURE_SPAWN
STRUCTURE_CONTAINER STRUCTURE_TOWER STRUCTURE_EXTENSION STRUCTURE_RAMPART
STRUCTURE_TERMINAL STRUCTURE_STORAGE STRUCTURE_EXTRACTOR STRUCTURE_LAB
STRUCTURE_NUKER STRUCTURE_POWER_SPAWN STRUCTURE_OBSERVER LOOK_STRUCTURES
LOOK_CONSTRUCTION_SITES CONSTRUCTION_COST CREEP_LIFE_TIME MAX_CONSTRUCTION_SITES
Severity: Major
Found in src/room/room-manager.ts - About 1 day to fix

    Function manageStructures has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

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

        manageExtractors() {
            const plannedLocations = this.roomPlanner.getLocations('extractor');
            if (plannedLocations.length <= CONTROLLER_STRUCTURES[STRUCTURE_EXTRACTOR][this.room.controller.level]) {
                this.buildPlannedStructures('extractor', STRUCTURE_EXTRACTOR);
                return;
    Severity: Minor
    Found in src/room/room-manager.ts - About 4 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 buildEndgameStructures has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        buildEndgameStructures() {
            if (this.room.terminal) {
                // Once there is a terminal, build quad-breaker walls.
                this.buildPlannedStructures('wall.quad', STRUCTURE_WALL);
            }
    Severity: Minor
    Found in src/room/room-manager.ts - About 4 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 cleanRoom has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        cleanRoom() {
            // Remove all extensions and labs blocking roads or bays (from redesigning rooms).
            for (const extension of this.structuresByType[STRUCTURE_EXTENSION] || []) {
                if (this.roomPlanner.isPlannedLocation(extension.pos, 'extension')) continue;
                if (!this.roomPlanner.isPlannedLocation(extension.pos, 'road')) continue;
    Severity: Minor
    Found in src/room/room-manager.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 manageStructures has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        manageStructures() {
            if (_.size(Game.spawns) === 1 && _.sample(Game.spawns).room.name === this.room.name && this.room.controller.level < 4) {
                // In our first room, getting more extensions is pretty important for
                // spawning bigger creeps asap.
                this.manageExtensions();
    Severity: Major
    Found in src/room/room-manager.ts - About 3 hrs to fix

      RoomManager has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class RoomManager {
          room: Room;
          roomPlanner: RoomPlanner;
          memory: RoomManagerMemory;
          roomConstructionSites: ConstructionSite[];
      Severity: Minor
      Found in src/room/room-manager.ts - About 3 hrs to fix

        Function removeMisplacedSpawn has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            removeMisplacedSpawn(roomSpawns) {
                for (const spawn of roomSpawns) {
                    if (this.roomPlanner.isPlannedLocation(spawn.pos, 'spawn')) continue;
        
                    // Only destroy spawn if there are enough resources and builders available.
        Severity: Minor
        Found in src/room/room-manager.ts - About 2 hrs to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function getDismantleTarget has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            getDismantleTarget() {
                if (!this.needsDismantling()) return null;
        
                for (const id of _.keys(this.memory.dismantle)) {
                    const structure = Game.getObjectById<AnyOwnedStructure>(id);
        Severity: Minor
        Found in src/room/room-manager.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 buildEndgameStructures has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            buildEndgameStructures() {
                if (this.room.terminal) {
                    // Once there is a terminal, build quad-breaker walls.
                    this.buildPlannedStructures('wall.quad', STRUCTURE_WALL);
                }
        Severity: Minor
        Found in src/room/room-manager.ts - About 1 hr to fix

          Function cleanRoom has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              cleanRoom() {
                  // Remove all extensions and labs blocking roads or bays (from redesigning rooms).
                  for (const extension of this.structuresByType[STRUCTURE_EXTENSION] || []) {
                      if (this.roomPlanner.isPlannedLocation(extension.pos, 'extension')) continue;
                      if (!this.roomPlanner.isPlannedLocation(extension.pos, 'road')) continue;
          Severity: Minor
          Found in src/room/room-manager.ts - About 1 hr to fix

            Function tryBuild has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                tryBuild(pos: RoomPosition, structureType) {
                    // Check if there's a structure here already.
                    const structures = pos.lookFor(LOOK_STRUCTURES);
                    for (const i in structures) {
                        if (structures[i].structureType === structureType) {
            Severity: Minor
            Found in src/room/room-manager.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 manageExtractors has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                manageExtractors() {
                    const plannedLocations = this.roomPlanner.getLocations('extractor');
                    if (plannedLocations.length <= CONTROLLER_STRUCTURES[STRUCTURE_EXTRACTOR][this.room.controller.level]) {
                        this.buildPlannedStructures('extractor', STRUCTURE_EXTRACTOR);
                        return;
            Severity: Minor
            Found in src/room/room-manager.ts - About 1 hr to fix

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

                  runLogic() {
                      if (!this.roomPlanner || !this.roomPlanner.isPlanningFinished()) return;
                      if (this.room.defense.getEnemyStrength() > ENEMY_STRENGTH_NONE && !this.room.controller?.safeMode) return;
              
                      delete this.memory.runNextTick;
              Severity: Minor
              Found in src/room/room-manager.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 removeUnplannedStructures has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  removeUnplannedStructures(locationType, structureType, amount?: number) {
                      const structures = this.structuresByType[structureType] || [];
                      const sites = this.constructionSitesByType[structureType] || [];
              
                      let limit = Math.min(CONTROLLER_STRUCTURES[structureType][this.room.controller.level], _.size(this.room.roomPlanner.getLocations(locationType)));
              Severity: Minor
              Found in src/room/room-manager.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 tryBuild has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  tryBuild(pos: RoomPosition, structureType) {
                      // Check if there's a structure here already.
                      const structures = pos.lookFor(LOOK_STRUCTURES);
                      for (const i in structures) {
                          if (structures[i].structureType === structureType) {
              Severity: Minor
              Found in src/room/room-manager.ts - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                                if (
                                    this.room.factory && (this.room.factory.level || 0) > 0
                                    && this.room.factoryManager && this.room.factoryManager.getFactoryLevel() > 0
                                    && this.room.factory.level !== this.room.factoryManager.getFactoryLevel()
                                ) {
                Severity: Major
                Found in src/room/room-manager.ts - About 40 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          if (!this.canCreateConstructionSites()) return;
                  Severity: Major
                  Found in src/room/room-manager.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            if (this.room.isEvacuating()) return;
                    Severity: Major
                    Found in src/room/room-manager.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              if (!this.canCreateConstructionSites()) return;
                      Severity: Major
                      Found in src/room/room-manager.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                if (!this.canCreateConstructionSites()) return;
                        Severity: Major
                        Found in src/room/room-manager.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

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

                            Avoid too many return statements within this function.
                            Open

                                    if (!this.canCreateConstructionSites()) return;
                            Severity: Major
                            Found in src/room/room-manager.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      if (!this.canCreateConstructionSites()) return;
                              Severity: Major
                              Found in src/room/room-manager.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        if (!this.checkWallIntegrity()) return;
                                Severity: Major
                                Found in src/room/room-manager.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          if (!this.canCreateConstructionSites()) return;
                                  Severity: Major
                                  Found in src/room/room-manager.ts - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

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

                                      Avoid too many return statements within this function.
                                      Open

                                              if (this.room.controller.level < 4) return;
                                      Severity: Major
                                      Found in src/room/room-manager.ts - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

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

                                          Avoid too many return statements within this function.
                                          Open

                                                  if (!this.canCreateConstructionSites()) return;
                                          Severity: Major
                                          Found in src/room/room-manager.ts - About 30 mins to fix

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

                                                buildPlannedStructures(locationType: string, structureType: StructureConstant, filterCallback?: (pos: RoomPosition) => boolean): boolean {
                                                    let canBuildMore = true;
                                                    for (const pos of this.roomPlanner.getLocations(locationType)) {
                                                        if (filterCallback && !filterCallback(pos)) continue;
                                                        if (this.tryBuild(pos, structureType)) continue;
                                            Severity: Minor
                                            Found in src/room/room-manager.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

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

                                                checkWallIntegrity(minHits?: number) {
                                                    // @todo make this consistent with defense manager.
                                                    if (!minHits) minHits = hivemind.settings.get('minWallIntegrity');
                                                    const maxHealth = hivemind.settings.get('maxWallHealth');
                                            
                                            
                                            Severity: Minor
                                            Found in src/room/room-manager.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

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

                                                isRoomRecovering(): boolean {
                                                    if ((this.room.controller.safeMode ?? 0) > 5000) return false;
                                                    if (this.room.needsReclaiming()) return true;
                                            
                                                    if (this.structuresByType[STRUCTURE_SPAWN] && this.structuresByType[STRUCTURE_SPAWN].length > 0) return false;
                                            Severity: Minor
                                            Found in src/room/room-manager.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

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

                                                scoreExtractorPositions(positions: RoomPosition[]): ScoredExtractorPosition[] {
                                                    const result: ScoredExtractorPosition[] = [];
                                            
                                                    for (const position of positions) {
                                                        const mineral = position.lookFor(LOOK_MINERALS)[0];
                                            Severity: Minor
                                            Found in src/room/room-manager.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

                                                    for (const lab of this.structuresByType[STRUCTURE_LAB] || []) {
                                                        if (this.roomPlanner.isPlannedLocation(lab.pos, 'lab')) continue;
                                                        if (
                                                            !this.roomPlanner.isPlannedLocation(lab.pos, 'road')
                                                            && !this.roomPlanner.isPlannedLocation(lab.pos, 'spawn')
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 1 other location - About 4 hrs to fix
                                            src/room/room-manager.ts on lines 183..193

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

                                            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

                                                    for (const lab of this.structuresByType[STRUCTURE_LINK] || []) {
                                                        if (this.roomPlanner.isPlannedLocation(lab.pos, 'link')) continue;
                                                        if (
                                                            !this.roomPlanner.isPlannedLocation(lab.pos, 'road')
                                                            && !this.roomPlanner.isPlannedLocation(lab.pos, 'spawn')
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 1 other location - About 4 hrs to fix
                                            src/room/room-manager.ts on lines 171..181

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

                                            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

                                                hasMisplacedStorage(): boolean {
                                                    if (!this.room.storage) return false;
                                                    if (!this.roomPlanner) return false;
                                                    if (this.roomPlanner.isPlannedLocation(this.room.storage.pos, 'storage')) return false;
                                            
                                            
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 1 other location - About 2 hrs to fix
                                            src/room/room-manager.ts on lines 696..702

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

                                            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

                                                hasMisplacedTerminal(): boolean {
                                                    if (!this.room.terminal) return false;
                                                    if (!this.roomPlanner) return false;
                                                    if (this.roomPlanner.isPlannedLocation(this.room.terminal.pos, 'terminal')) return false;
                                            
                                            
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 1 other location - About 2 hrs to fix
                                            src/room/room-manager.ts on lines 682..688

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

                                            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 (hivemind.settings.get('constructPowerSpawns')) {
                                                        // Make sure all current power spawns have been built.
                                                        if (_.size(this.roomConstructionSites) === 0) this.removeUnplannedStructures('powerSpawn', STRUCTURE_POWER_SPAWN, 1);
                                                        this.buildPlannedStructures('powerSpawn', STRUCTURE_POWER_SPAWN);
                                                    }
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 2 other locations - About 1 hr to fix
                                            src/room/room-manager.ts on lines 796..800
                                            src/room/room-manager.ts on lines 812..816

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

                                            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 (hivemind.settings.get('constructNukers')) {
                                                        // Make sure all current nukers have been built.
                                                        if (_.size(this.roomConstructionSites) === 0) this.removeUnplannedStructures('nuker', STRUCTURE_NUKER, 1);
                                                        this.buildPlannedStructures('nuker', STRUCTURE_NUKER);
                                                    }
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 2 other locations - About 1 hr to fix
                                            src/room/room-manager.ts on lines 804..808
                                            src/room/room-manager.ts on lines 812..816

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

                                            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 (hivemind.settings.get('constructObservers')) {
                                                        // Make sure all current observers have been built.
                                                        if (_.size(this.roomConstructionSites) === 0) this.removeUnplannedStructures('observer', STRUCTURE_OBSERVER, 1);
                                                        this.buildPlannedStructures('observer', STRUCTURE_OBSERVER);
                                                    }
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 2 other locations - About 1 hr to fix
                                            src/room/room-manager.ts on lines 796..800
                                            src/room/room-manager.ts on lines 804..808

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

                                            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 (this.hasMisplacedStorage() && this.room.storage.store.getUsedCapacity() < 5000) {
                                                        this.removeUnplannedStructures('storage', STRUCTURE_STORAGE, 1);
                                                    }
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 1 other location - About 1 hr to fix
                                            src/room/room-manager.ts on lines 343..345

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

                                            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 (this.hasMisplacedTerminal() && this.room.terminal.store.getUsedCapacity() < 5000) {
                                                        this.removeUnplannedStructures('terminal', STRUCTURE_TERMINAL, 1);
                                                    }
                                            Severity: Major
                                            Found in src/room/room-manager.ts and 1 other location - About 1 hr to fix
                                            src/room/room-manager.ts on lines 334..336

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

                                            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 unwantedWalls = _.filter(
                                                            this.room.structuresByType[STRUCTURE_WALL],
                                                            structure => !this.roomPlanner.isPlannedLocation(structure.pos, 'wall'),
                                                        );
                                            Severity: Minor
                                            Found in src/room/room-manager.ts and 1 other location - About 30 mins to fix
                                            src/room/room-manager.ts on lines 380..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 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 2 locations. Consider refactoring.
                                            Open

                                                        const unwantedRamparts = hivemind.settings.get('dismantleUnwantedRamparts') ? _.filter(
                                                            this.room.structuresByType[STRUCTURE_RAMPART],
                                                            structure => !this.roomPlanner.isPlannedLocation(structure.pos, 'rampart'),
                                                        ) : [];
                                            Severity: Minor
                                            Found in src/room/room-manager.ts and 1 other location - About 30 mins to fix
                                            src/room/room-manager.ts on lines 376..379

                                            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