PlacementManager
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
export default class PlacementManager {
public get ROAD_POSITION() {
return 1;
}
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;
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);
- Read upRead up
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.
- Read upRead up
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;
- Read upRead up
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;
Avoid too many return
statements within this function. Open
if (matrixValue === this.ROAD_POSITION && !allowRoads) return false;
Avoid too many return
statements within this function. Open
if (matrixValue > 1) return false;
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;
- Read upRead up
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,
- Read upRead up
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"