Showing 886 of 1,349 total issues
Function registerCaravan
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
registerCaravan(id: string) {
if (!Memory.strategy) Memory.strategy = {};
if (!Memory.strategy.caravans) Memory.strategy.caravans = {};
const creeps = _.sortBy(_.filter(this.room.enemyCreeps[SYSTEM_USERNAME], c => c.name.startsWith(id)), c => c.name);
- 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 addIntershardSpawnOptionsFor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addIntershardSpawnOptionsFor(request: {name: string; safe: boolean; rcl: number; portalRoom?: string}, shardName: string, options: ReclaimSpawnOption[]) {
if (!request.portalRoom) return;
if (request.rcl < 4) return;
if (!request.safe) return;
- 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 balanceEnergyLevels
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
balanceEnergyLevels() {
const ratio = this.getRatio();
if (ratio >= 1 || ratio <= 0) {
// There's nothing to balance, all energy goes into one category.
Memory.energyBalace.gplEnergy = 0;
- 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 addLowLevelRoomSpawnOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addLowLevelRoomSpawnOptions(room: Room, options: RoomDefenseSpawnOption[]) {
// In low level rooms, add defenses!
if (room.controller.level >= 4) return;
if ((room.controller.safeMode || 0) > 500) return;
if (!room.memory.enemies || room.memory.enemies.safe) return;
- 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 addHaulerSpawnOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addHaulerSpawnOptions(room: Room, options: RemoteMiningSpawnOption[]) {
// @todo Reduce needed carry parts to account for energy spent on road maintenance.
// @todo Reduce needed carry parts to account for higher throughput with relays.
const maximumNeededCarryParts = this.getMaximumCarryParts(room);
const maxHaulerSize = this.getMaximumHaulerSize(room, maximumNeededCarryParts);
- 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 drawExpansionStatus
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
drawExpansionStatus() {
if (!Memory.strategy.expand) return;
// Visualize failed expansion attempts.
for (const attempt of Memory.strategy.expand.failedExpansions || []) {
- 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 needsSpawning
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
needsSpawning(room: Room, squad: Squad): SquadUnitType | null {
const neededUnits: SquadUnitType[] = [];
for (const unitType in squad.memory.composition) {
if (!availableUnitTypes.includes(unitType as SquadUnitType)) continue;
- 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 getClosestObserver
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getClosestObserver(roomName: string): StructureObserver {
let bestObserver: StructureObserver = null;
for (const observer of this.observers) {
const roomDist = Game.map.getRoomLinearDistance(observer.room.name, roomName);
if (roomDist > OBSERVER_RANGE) continue;
- 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 addIntershardSpawnOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addIntershardSpawnOptions(options: ReclaimSpawnOption[]) {
const interShardMemory = interShard.getLocalMemory();
for (const shardName in (interShardMemory.portals || {})) {
const shardMemory = interShard.getRemoteMemory(shardName);
if (!shardMemory?.info?.rooms?.reclaimable) continue;
- 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 generateScoutTargets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
generateScoutTargets() {
const roomList = Memory.strategy.roomList || {};
const openList = this.getScoutOrigins();
const closedList: Record<string, boolean> = {};
- 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 scoreExtractorPositions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
scoreExtractorPositions(positions: RoomPosition[]): ScoredExtractorPosition[] {
const result: ScoredExtractorPosition[] = [];
for (const position of positions) {
const mineral = position.lookFor(LOOK_MINERALS)[0];
- 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 checkWallIntegrity
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
checkWallIntegrity(minHits?: number) {
// @todo make this consistent with defense manager.
if (!minHits) minHits = hivemind.settings.get('minWallIntegrity');
const maxHealth = hivemind.settings.get('maxWallHealth');
- 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 getAllRequestedBoosts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private getAllRequestedBoosts(): Partial<Record<ResourceConstant, number>> {
const boosts = {};
for (const creepName in this.memory.creeps) {
if (Game.creeps[creepName]?.room?.name !== this.room.name) continue;
- 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 placeRoadNetwork
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
placeRoadNetwork(): StepResult {
// Find paths from each exit towards the room center for making roads.
for (const dir of _.keys(this.exitCenters)) {
for (const pos of this.exitCenters[dir]) {
const exitRoads = this.placementManager.findAccessRoad(pos, this.roomCenterEntrances);
- 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 buildEndgameStructures
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
buildEndgameStructures() {
if (this.room.terminal) {
// Once there is a terminal, build quad-breaker walls.
this.buildPlannedStructures('wall.quad', STRUCTURE_WALL);
}
- 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 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"
Further reading
Function placeHarvestBayStructures
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
placeHarvestBayStructures(): StepResult {
const roomIntel = getRoomIntel(this.roomName);
for (const source of roomIntel.getSourcePositions()) {
const shouldAddSpawn = this.variationInfo.sourcesWithSpawn.includes(source.id);
const harvestPosition = this.sourceInfo[source.id].harvestPosition;
- 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 cleanExtensions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
cleanExtensions() {
for (const extension of this.structuresByType[STRUCTURE_EXTENSION] || []) {
if (this.roomPlanner.isPlannedLocation(extension.pos, 'extension')) continue;
if (!this.roomPlanner.isPlannedLocation(extension.pos, 'road')) continue;
- 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 buildPlannedStructures
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
buildPlannedStructures(locationType: string, structureType: StructureConstant, filterCallback?: (pos: RoomPosition) => boolean): boolean {
let canBuildMore = true;
for (const pos of this.roomPlanner.getLocations(locationType)) {
if (filterCallback && !filterCallback(pos)) continue;
if (this.tryBuild(pos, structureType)) continue;
- 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"