Mirroar/hivemind

View on GitHub
src/prototype/creep.movement.ts

Summary

Maintainability
F
1 wk
Test Coverage

File creep.movement.ts has 733 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global Creep PowerCreep RoomVisual RoomPosition LOOK_CREEPS OK
LOOK_CONSTRUCTION_SITES ERR_NO_PATH LOOK_STRUCTURES LOOK_POWER_CREEPS */

import cache from 'utils/cache';
import container from 'utils/container';
Severity: Major
Found in src/prototype/creep.movement.ts - About 1 day to fix

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

    Creep.prototype.getOntoCachedPath = function (this: Creep | PowerCreep) {
        const creep = this;
        const target = this.pos.findClosestByRange(this.getCachedPath(), {
            filter: pos => {
                // Try to move to a position on the path that is in the current room.
    Severity: Minor
    Found in src/prototype/creep.movement.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 goTo has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.goTo = function (this: Creep | PowerCreep, target: RoomObject | RoomPosition, options: GoToOptions) {
        if (!target) return false;
        if (!options) options = {};
    
        container.get('TrafficManager').setMoving(this);
    Severity: Minor
    Found in src/prototype/creep.movement.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 moveUsingNavMesh has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.moveUsingNavMesh = function (this: Creep | PowerCreep, targetPos, options) {
        if (!hivemind.segmentMemory.isReady()) return OK;
    
        if (!options) options = {};
    
    
    Severity: Minor
    Found in src/prototype/creep.movement.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 followCachedPath has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.followCachedPath = function (this: Creep | PowerCreep) {
        drawCreepMovement(this);
    
        container.get('TrafficManager').setMoving(this);
        this.heapMemory._moveBlocked = false;
    Severity: Minor
    Found in src/prototype/creep.movement.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 manageBlockingCreeps has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.manageBlockingCreeps = function (this: Creep | PowerCreep) {
        const path = this.getCachedPath();
        if (typeof this.memory.cachedPath.position === 'undefined' || this.memory.cachedPath.position === null) {
            for (const pos of path) {
                // @todo Look for the _furthest_ position that is in range 1.
    Severity: Minor
    Found in src/prototype/creep.movement.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 getOntoCachedPath has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Creep.prototype.getOntoCachedPath = function (this: Creep | PowerCreep) {
        const creep = this;
        const target = this.pos.findClosestByRange(this.getCachedPath(), {
            filter: pos => {
                // Try to move to a position on the path that is in the current room.
    Severity: Major
    Found in src/prototype/creep.movement.ts - About 2 hrs to fix

      Function goTo has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Creep.prototype.goTo = function (this: Creep | PowerCreep, target: RoomObject | RoomPosition, options: GoToOptions) {
          if (!target) return false;
          if (!options) options = {};
      
          container.get('TrafficManager').setMoving(this);
      Severity: Major
      Found in src/prototype/creep.movement.ts - About 2 hrs to fix

        Function moveUsingNavMesh has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Creep.prototype.moveUsingNavMesh = function (this: Creep | PowerCreep, targetPos, options) {
            if (!hivemind.segmentMemory.isReady()) return OK;
        
            if (!options) options = {};
        
        
        Severity: Major
        Found in src/prototype/creep.movement.ts - About 2 hrs to fix

          Function followCachedPath has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Creep.prototype.followCachedPath = function (this: Creep | PowerCreep) {
              drawCreepMovement(this);
          
              container.get('TrafficManager').setMoving(this);
              this.heapMemory._moveBlocked = false;
          Severity: Major
          Found in src/prototype/creep.movement.ts - About 2 hrs to fix

            Function moveAroundObstacles has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Creep.prototype.moveAroundObstacles = function (this: Creep | PowerCreep) {
                const REMEMBER_POSITION_COUNT = 5;
            
                // Record recent positions the creep has been on.
                // @todo Using Game.time here is unwise in case the creep is being throttled.
            Severity: Minor
            Found in src/prototype/creep.movement.ts - About 1 hr to fix

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

              function drawCreepMovement(creep: Creep | PowerCreep) {
                  if (!RoomVisual) return;
                  if (!settings.get('visualizeCreepMovement')) return;
                  if (settings.get('disableRoomVisuals')) return;
              
              
              Severity: Minor
              Found in src/prototype/creep.movement.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 drawCreepMovement has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function drawCreepMovement(creep: Creep | PowerCreep) {
                  if (!RoomVisual) return;
                  if (!settings.get('visualizeCreepMovement')) return;
                  if (settings.get('disableRoomVisuals')) return;
              
              
              Severity: Minor
              Found in src/prototype/creep.movement.ts - About 1 hr to fix

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

                Creep.prototype.moveAroundObstacles = function (this: Creep | PowerCreep) {
                    const REMEMBER_POSITION_COUNT = 5;
                
                    // Record recent positions the creep has been on.
                    // @todo Using Game.time here is unwise in case the creep is being throttled.
                Severity: Minor
                Found in src/prototype/creep.movement.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 manageBlockingCreeps has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Creep.prototype.manageBlockingCreeps = function (this: Creep | PowerCreep) {
                    const path = this.getCachedPath();
                    if (typeof this.memory.cachedPath.position === 'undefined' || this.memory.cachedPath.position === null) {
                        for (const pos of path) {
                            // @todo Look for the _furthest_ position that is in range 1.
                Severity: Minor
                Found in src/prototype/creep.movement.ts - About 1 hr to fix

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

                  Creep.prototype.interRoomTravel = function (this: Creep | PowerCreep, targetPos, allowDanger = false): boolean {
                      const isInTargetRoom = this.pos.roomName === targetPos.roomName;
                      if (!isInTargetRoom || (!this.isInRoom() && this.getNavMeshMoveTarget())) {
                          if (this.heapMemory.moveWithoutNavMesh) {
                              if (!this.moveToRoom(targetPos.roomName, allowDanger)) {
                  Severity: Minor
                  Found in src/prototype/creep.movement.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 setCachedPath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Creep.prototype.setCachedPath = function (this: Creep | PowerCreep, path, reverse, distance) {
                      path = _.clone(path);
                      if (reverse || distance) {
                          const originalPath = deserializePositionPath(path);
                          if (reverse) {
                  Severity: Minor
                  Found in src/prototype/creep.movement.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 canMoveOnto has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Creep.prototype.canMoveOnto = function (this: Creep | PowerCreep, position) {
                      const creeps = position.lookFor(LOOK_CREEPS);
                      if (creeps.length > 0 && creeps[0].id !== this.id && !isMovingCreep(creeps[0])) return false;
                  
                      const powerCreeps = position.lookFor(LOOK_POWER_CREEPS);
                  Severity: Minor
                  Found in src/prototype/creep.movement.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

                  Avoid deeply nested control flow statements.
                  Open

                                                  if (costs.get(pos.x, pos.y) <= 20) {
                                                      costs.set(pos.x, pos.y, 20);
                                                  }
                  Severity: Major
                  Found in src/prototype/creep.movement.ts - About 45 mins to fix

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

                    Creep.prototype.incrementCachedPathPosition = function (this: Creep | PowerCreep) {
                        // Check if we've already moved onto the next position.
                        const path = this.getCachedPath();
                        const next = path[this.memory.cachedPath.position + 1];
                        if (!next) {
                    Severity: Minor
                    Found in src/prototype/creep.movement.ts - About 35 mins to fix

                    Cognitive Complexity

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

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

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

                    Further reading

                    Avoid too many return statements within this function.
                    Open

                                return OK;
                    Severity: Major
                    Found in src/prototype/creep.movement.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return false;
                      Severity: Major
                      Found in src/prototype/creep.movement.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            if (!pos || pos.roomName !== this.pos.roomName) return;
                        Severity: Major
                        Found in src/prototype/creep.movement.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              if (!target) return;
                          Severity: Major
                          Found in src/prototype/creep.movement.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return true;
                            Severity: Major
                            Found in src/prototype/creep.movement.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return ERR_NO_PATH;
                              Severity: Major
                              Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    if (this.moveAroundObstacles()) return;
                                Severity: Major
                                Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      if (lineStartPos.roomName !== target.roomName) return;
                                  Severity: Major
                                  Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                if (portalUsed) return OK;
                                    Severity: Major
                                    Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                          if (this.memory.cachedPath.arrived) return;
                                      Severity: Major
                                      Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return;
                                        Severity: Major
                                        Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                              return true;
                                          Severity: Major
                                          Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                return OK;
                                            Severity: Major
                                            Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return;
                                              Severity: Major
                                              Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                            return ERR_NO_PATH;
                                                Severity: Major
                                                Found in src/prototype/creep.movement.ts - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          return;
                                                  Severity: Major
                                                  Found in src/prototype/creep.movement.ts - About 30 mins to fix

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

                                                    Creep.prototype.calculatePath = function (this: Creep | PowerCreep, target: RoomPosition, options?: GoToOptions): RoomPosition[] {
                                                        if (!options) options = {};
                                                    
                                                        // @todo Properly type this.
                                                        const pfOptions: any = {};
                                                    Severity: Minor
                                                    Found in src/prototype/creep.movement.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 moveToRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                    Creep.prototype.moveToRoom = function (this: Creep | PowerCreep, roomName, allowDanger) {
                                                        // Make sure we recalculate path if target changes.
                                                        if (this.heapMemory._mtrTarget !== roomName) {
                                                            delete this.heapMemory._mtrNextRoom;
                                                            this.heapMemory._mtrTarget = roomName;
                                                    Severity: Minor
                                                    Found in src/prototype/creep.movement.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

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

                                                            if (path[0].roomName === this.pos.roomName) {
                                                                this.move(this.pos.getDirectionTo(path[0]));
                                                    
                                                                const creep = path[0].lookFor(LOOK_CREEPS)[0];
                                                                if (creep) container.get('TrafficManager').setBlockingCreep(this, creep);
                                                    Severity: Major
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 6 hrs to fix
                                                    src/prototype/creep.movement.ts on lines 383..393

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

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

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

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

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

                                                    Refactorings

                                                    Further Reading

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

                                                                if (path[0].roomName === this.pos.roomName) {
                                                                    this.move(this.pos.getDirectionTo(path[0]));
                                                    
                                                                    const creep = path[0].lookFor(LOOK_CREEPS)[0];
                                                                    if (creep) container.get('TrafficManager').setBlockingCreep(this, creep);
                                                    Severity: Major
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 6 hrs to fix
                                                    src/prototype/creep.movement.ts on lines 437..447

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

                                                    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 (settings.get('visualizeCreepMovement') && !settings.get('disableRoomVisuals')) {
                                                                this.room.visual.poly(path, {
                                                                    fill: 'transparent',
                                                                    stroke: '#fff',
                                                                    lineStyle: 'dashed',
                                                    Severity: Major
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 2 hrs to fix
                                                    src/prototype/creep.movement.ts on lines 290..298

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

                                                    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 (settings.get('visualizeCreepMovement') && !settings.get('disableRoomVisuals')) {
                                                                    this.room.visual.poly(path, {
                                                                        fill: 'transparent',
                                                                        stroke: '#f00',
                                                                        lineStyle: 'dashed',
                                                    Severity: Major
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 2 hrs to fix
                                                    src/prototype/creep.movement.ts on lines 425..433

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

                                                    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(Game.rooms[roomName].roomPlanner.getLocations('bay_center'), pos => {
                                                                                    if (costs.get(pos.x, pos.y) <= 20) {
                                                                                        costs.set(pos.x, pos.y, 20);
                                                                                    }
                                                                                });
                                                    Severity: Major
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 1 hr to fix
                                                    src/room-intel.ts on lines 748..752

                                                    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 (powerCreeps.length > 0 && powerCreeps[0].id !== this.id && !isMovingCreep(powerCreeps[0])) return false;
                                                    Severity: Minor
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 40 mins to fix
                                                    src/prototype/creep.movement.ts on lines 629..629

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

                                                    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 (creeps.length > 0 && creeps[0].id !== this.id && !isMovingCreep(creeps[0])) return false;
                                                    Severity: Minor
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 40 mins to fix
                                                    src/prototype/creep.movement.ts on lines 632..632

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

                                                    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 (pos.x === 0 || pos.x === 49 || pos.y === 0 || pos.y === 49) return false;
                                                    Severity: Minor
                                                    Found in src/prototype/creep.movement.ts and 1 other location - About 30 mins to fix
                                                    src/utils/mincut.ts on lines 520..520

                                                    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