Mirroar/hivemind

View on GitHub
src/prototype/room.resources.ts

Summary

Maintainability
F
6 days
Test Coverage

File room.resources.ts has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global Room RoomPosition RESOURCE_ENERGY LOOK_RESOURCES
RESOURCE_POWER STRUCTURE_LAB RESOURCES_ALL */

import cache from 'utils/cache';
import container from 'utils/container';
Severity: Minor
Found in src/prototype/room.resources.ts - About 7 hrs to fix

    Function getResourceLevelCutoffs has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.getResourceLevelCutoffs = function (this: Room, resourceType: ResourceConstant): ResourceLevelCuttoffs {
        if (resourceType === RESOURCE_ENERGY) {
            // Defending rooms need energy to defend.
            if (this.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL) return [1_000_000, 100_000, 50_000];
    
    
    Severity: Minor
    Found in src/prototype/room.resources.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 getBestStorageTarget has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.getBestStorageTarget = function (this: Room, amount, resourceType) {
        if (this.storage && this.terminal) {
            const storageFree = this.storage.store.getFreeCapacity();
            const terminalFree = this.terminal.store.getFreeCapacity();
            if (this.isEvacuating() && terminalFree > this.terminal.store.getCapacity() * 0.2) {
    Severity: Minor
    Found in src/prototype/room.resources.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 getStoredEnergy has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.getStoredEnergy = function (this: Room) {
        return cache.inObject(this, 'storedEnergy', 1, () => {
            let total = this.getCurrentResourceAmount(RESOURCE_ENERGY);
    
            // Add energy on storage location (pre storage).
    Severity: Minor
    Found in src/prototype/room.resources.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 getResourceLevelCutoffs has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Room.prototype.getResourceLevelCutoffs = function (this: Room, resourceType: ResourceConstant): ResourceLevelCuttoffs {
        if (resourceType === RESOURCE_ENERGY) {
            // Defending rooms need energy to defend.
            if (this.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL) return [1_000_000, 100_000, 50_000];
    
    
    Severity: Major
    Found in src/prototype/room.resources.ts - About 2 hrs to fix

      Function getResourceState has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Room.prototype.getResourceState = function (this: Room) {
          if (!this.isMine()) return null;
      
          const storage = this.storage;
          const terminal = this.terminal;
      Severity: Minor
      Found in src/prototype/room.resources.ts - About 1 hr to fix

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

        Room.prototype.getBestStorageSource = function (this: Room, resourceType: ResourceConstant) {
            if (this.storage && this.terminal) {
                const specialSource = this.getBestCircumstancialStorageSource(resourceType);
                if (specialSource) return specialSource;
        
        
        Severity: Minor
        Found in src/prototype/room.resources.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 getBestStorageTarget has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Room.prototype.getBestStorageTarget = function (this: Room, amount, resourceType) {
            if (this.storage && this.terminal) {
                const storageFree = this.storage.store.getFreeCapacity();
                const terminalFree = this.terminal.store.getFreeCapacity();
                if (this.isEvacuating() && terminalFree > this.terminal.store.getCapacity() * 0.2) {
        Severity: Minor
        Found in src/prototype/room.resources.ts - About 1 hr to fix

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

          Room.prototype.getBestCircumstancialStorageSource = function (this: Room, resourceType: ResourceConstant) {
              let primarySource: StructureStorage | StructureTerminal;
              let secondarySource: StructureStorage | StructureTerminal;
              if (this.isEvacuating()) {
                  // Take resources out of storage if possible to empty it out.
          Severity: Minor
          Found in src/prototype/room.resources.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 isDangerous has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          const isDangerous = function (this: Source | Mineral) {
              const lair = this.getNearbyLair();
              if (!lair || !lair.isDangerous()) return false;
          
              // It's still safe if a guardian with sufficient lifespan is nearby to take
          Severity: Minor
          Found in src/prototype/room.resources.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 [10_000, 5000, 1000];
          Severity: Major
          Found in src/prototype/room.resources.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return [30_000, 10_000, 2000];
            Severity: Major
            Found in src/prototype/room.resources.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return [10_000, 5000, 500];
              Severity: Major
              Found in src/prototype/room.resources.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return this.terminal;
                Severity: Major
                Found in src/prototype/room.resources.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return null;
                  Severity: Major
                  Found in src/prototype/room.resources.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            if (!this.factory) return [1, 0, 0];
                    Severity: Major
                    Found in src/prototype/room.resources.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return this.storage;
                      Severity: Major
                      Found in src/prototype/room.resources.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                if (!isCommodityNeededAtFactoryLevel(this.factory.getEffectiveLevel(), resourceType)) return [1, 0, 0];
                        Severity: Major
                        Found in src/prototype/room.resources.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return [50_000, 30_000, 10_000];
                          Severity: Major
                          Found in src/prototype/room.resources.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return [50_000, 0, 0];
                            Severity: Major
                            Found in src/prototype/room.resources.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return this.terminal;
                              Severity: Major
                              Found in src/prototype/room.resources.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return this.terminal;
                                Severity: Major
                                Found in src/prototype/room.resources.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          if (bodyPart === WORK && BOOSTS[bodyPart][resourceType].upgradeController && this.controller.level >= 8) return [15_000, 7500, 2500];
                                  Severity: Major
                                  Found in src/prototype/room.resources.ts - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return this.storage;
                                    Severity: Major
                                    Found in src/prototype/room.resources.ts - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return [50_000, 30_000, 10_000];
                                      Severity: Major
                                      Found in src/prototype/room.resources.ts - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                if (!this.factory) return [1, 0, 0];
                                        Severity: Major
                                        Found in src/prototype/room.resources.ts - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              return null;
                                          Severity: Major
                                          Found in src/prototype/room.resources.ts - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    if (bodyPart === WORK && BOOSTS[bodyPart][resourceType].repair && this.defense.getEnemyStrength() > ENEMY_STRENGTH_NORMAL) return [15_000, 7500, 2500];
                                            Severity: Major
                                            Found in src/prototype/room.resources.ts - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return this.storage;
                                              Severity: Major
                                              Found in src/prototype/room.resources.ts - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        if ((bodyPart === ATTACK || bodyPart === RANGED_ATTACK) && this.defense.getEnemyStrength() > ENEMY_STRENGTH_NORMAL) return [15_000, 7500, 2500];
                                                Severity: Major
                                                Found in src/prototype/room.resources.ts - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          if (_.filter(Game.powerCreeps, c => c.pos && c.pos.roomName === this.name).length === 0) return [1, 0, 0];
                                                  Severity: Major
                                                  Found in src/prototype/room.resources.ts - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                return this.terminal;
                                                    Severity: Major
                                                    Found in src/prototype/room.resources.ts - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                              return this.terminal;
                                                      Severity: Major
                                                      Found in src/prototype/room.resources.ts - About 30 mins to fix

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

                                                        function isCommodityNeededAtFactoryLevel(factoryLevel: number, resourceType: ResourceConstant): boolean {
                                                            for (const productType in COMMODITIES) {
                                                                const recipe = COMMODITIES[productType];
                                                                if (recipe.level && recipe.level !== factoryLevel) continue;
                                                                if (recipe.components[resourceType]) return true;
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.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

                                                            if (this.terminal && !this.isClearingTerminal()) {
                                                                // Only count terminal resources if we count it's free capacity.
                                                                limit -= Math.min(this.terminal.store.getCapacity(), this.terminal.store.getUsedCapacity());
                                                            }
                                                        Severity: Major
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 1 hr to fix
                                                        src/prototype/room.resources.ts on lines 118..121

                                                        Duplicated Code

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

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

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

                                                        Tuning

                                                        This issue has a mass of 72.

                                                        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.storage && !this.isClearingStorage()) {
                                                                // Only count storage resources if we count it's free capacity.
                                                                limit -= Math.min(this.storage.store.getCapacity(), this.storage.store.getUsedCapacity());
                                                            }
                                                        Severity: Major
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 1 hr to fix
                                                        src/prototype/room.resources.ts on lines 123..126

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

                                                        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

                                                        Object.defineProperty(Room.prototype, 'sourceDispatcher', {
                                                            get(this: Room) {
                                                                return cache.inObject(this, 'sourceDispatcher', 1, () => new ResourceSourceDispatcher(this));
                                                            },
                                                            enumerable: false,
                                                        Severity: Major
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 1 hr to fix
                                                        src/prototype/room.resources.ts on lines 77..83

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

                                                        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

                                                        Object.defineProperty(Room.prototype, 'destinationDispatcher', {
                                                            get(this: Room) {
                                                                return cache.inObject(this, 'destinationDispatcher', 1, () => new ResourceDestinationDispatcher(this));
                                                            },
                                                            enumerable: false,
                                                        Severity: Major
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 1 hr to fix
                                                        src/prototype/room.resources.ts on lines 68..74

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

                                                        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

                                                        Room.prototype.isFullOnPower = function (this: Room) {
                                                            return this.getCurrentResourceAmount(RESOURCE_POWER) > this.getStorageLimit() / 6;
                                                        };
                                                        Severity: Major
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 1 hr to fix
                                                        src/prototype/room.resources.ts on lines 252..254

                                                        Duplicated Code

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

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

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

                                                        Tuning

                                                        This issue has a mass of 57.

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                        Room.prototype.isFullOnEnergy = function (this: Room) {
                                                            return this.getCurrentResourceAmount(RESOURCE_ENERGY) > this.getStorageLimit() / 2;
                                                        };
                                                        Severity: Major
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 1 hr to fix
                                                        src/prototype/room.resources.ts on lines 262..264

                                                        Duplicated Code

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

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

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

                                                        Tuning

                                                        This issue has a mass of 57.

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                            _.each(this.creepsByRole.transporter, creep => {
                                                                total += creep.store.getUsedCapacity(resourceType as ResourceConstant);
                                                            });
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 45 mins to fix
                                                        src/prototype/room.resources.ts on lines 162..164

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

                                                        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

                                                                _.each(this.creepsByRole.hauler, creep => {
                                                                    total += creep.store.getUsedCapacity(resourceType as ResourceConstant);
                                                                });
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 45 mins to fix
                                                        src/prototype/room.resources.ts on lines 156..158

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

                                                        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.storage && !this.isClearingStorage()) {
                                                                total += this.storage.store.getCapacity();
                                                            }
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 35 mins to fix
                                                        src/prototype/room.resources.ts on lines 97..99

                                                        Duplicated Code

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

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

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

                                                        Tuning

                                                        This issue has a mass of 46.

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                            if (this.terminal && !this.isClearingTerminal()) {
                                                                total += this.terminal.store.getCapacity();
                                                            }
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 35 mins to fix
                                                        src/prototype/room.resources.ts on lines 93..95

                                                        Duplicated Code

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

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

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

                                                        Tuning

                                                        This issue has a mass of 46.

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

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

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

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

                                                        Refactorings

                                                        Further Reading

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

                                                                    _.each(storage.store, (amount: number, resourceType: ResourceConstant) => {
                                                                        roomData.addResource(resourceType, amount);
                                                                    });
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 30 mins to fix
                                                        src/prototype/room.resources.ts on lines 440..442

                                                        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

                                                                    _.each(terminal.store, (amount: number, resourceType: ResourceConstant) => {
                                                                        roomData.addResource(resourceType, amount);
                                                                    });
                                                        Severity: Minor
                                                        Found in src/prototype/room.resources.ts and 1 other location - About 30 mins to fix
                                                        src/prototype/room.resources.ts on lines 433..435

                                                        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