Mirroar/hivemind

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

Summary

Maintainability
C
1 day
Test Coverage

PlacementManager has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class PlacementManager {
    public get ROAD_POSITION() {
        return 1;
    }

Severity: Minor
Found in src/room/planner/placement-manager.ts - About 2 hrs to fix

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

        getNextAvailableBuildSpot(): RoomPosition {
            while (_.size(this.openList) > 0) {
                let minDist = null;
                let nextPos = null;
                let nextInfo = null;
    Severity: Minor
    Found in src/room/planner/placement-manager.ts - About 1 hr to fix

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

          prepareBuildingMatrix() {
              for (let x = 0; x < 50; x++) {
                  for (let y = 0; y < 50; y++) {
                      if (this.terrain.get(x, y) === TERRAIN_MASK_WALL) {
                          this.buildingMatrix.set(x, y, this.ROAD_THROUGH_WALL_COST);
      Severity: Minor
      Found in src/room/planner/placement-manager.ts - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          isBuildableTile(x: number, y: number, allowRoads?: boolean, allowNearExit?: boolean): boolean {
              // Only build on valid terrain.
              if (this.terrain.get(x, y) === TERRAIN_MASK_WALL) return false;
      
              // Don't build too close to exits.
      Severity: Minor
      Found in src/room/planner/placement-manager.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 getNextAvailableBuildSpot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          getNextAvailableBuildSpot(): RoomPosition {
              while (_.size(this.openList) > 0) {
                  let minDist = null;
                  let nextPos = null;
                  let nextInfo = null;
      Severity: Minor
      Found in src/room/planner/placement-manager.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 true;
      Severity: Major
      Found in src/room/planner/placement-manager.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                if (matrixValue === this.ROAD_POSITION && !allowRoads) return false;
        Severity: Major
        Found in src/room/planner/placement-manager.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  if (matrixValue > 1) return false;
          Severity: Major
          Found in src/room/planner/placement-manager.ts - About 30 mins to fix

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

                findAccessRoad(from: RoomPosition, to: RoomPosition | RoomPosition[], breakExtensions?: boolean): RoomPosition[] {
                    const result = PathFinder.search(from, to, {
                        roomCallback: () => {
                            if (!breakExtensions) return this.buildingMatrix;
            
            
            Severity: Minor
            Found in src/room/planner/placement-manager.ts - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                isPositionAccessible(pos: RoomPosition, noTunnels?: boolean) {
                    // We don't care about cost, just about possibility.
                    const result = PathFinder.search(pos, this.originEntrances, {
                        roomCallback: () => this.buildingMatrix,
                        maxRooms: 1,
            Severity: Minor
            Found in src/room/planner/placement-manager.ts - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            There are no issues that match your filters.

            Category
            Status