Showing 899 of 1,362 total issues
File builder.mines.ts
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global FIND_DROPPED_RESOURCES RESOURCE_ENERGY OK
ERR_NO_PATH ERR_NOT_IN_RANGE FIND_STRUCTURES STRUCTURE_CONTAINER STRUCTURE_ROAD
FIND_MY_CONSTRUCTION_SITES LOOK_STRUCTURES MAX_CONSTRUCTION_SITES
LOOK_CONSTRUCTION_SITES */
Function performRemoteBuild
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
performRemoteBuild() {
const creep: Creep = this.creep;
// Try and prevent controller downgrades.
if (creep.room.isMine() && !creep.room.controller.upgradeBlocked && (creep.room.controller.level < 2 || creep.room.controller.ticksToDowngrade < 500)) {
- 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 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) {
- 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 getDismantlePositions
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
getDismantlePositions(sourceLocation: string): RoomPosition[] {
if (!hivemind.segmentMemory.isReady()) return [];
// No dismantlers for SK rooms, they get confused easily...
const roomIntel = getRoomIntel(this.roomName);
- 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 getRemoteMiningSourceRooms
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
getRemoteMiningSourceRooms(): Record<string, SourceRoomAvailability> {
const sourceRooms: Record<string, SourceRoomAvailability> = {};
// Determine how much remote mining each room can handle.
for (const room of Game.myRooms) {
- 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 assertMilitaryCreepPower
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.assertMilitaryCreepPower = function (this: Room, creep: Creep | PowerCreep) {
let hostile: boolean;
let targets: Array<Creep | PowerCreep>;
let allies: Array<Creep | PowerCreep>;
if (creep.my) {
- 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 run
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
run() {
// @todo Find labs not used for reactions, to do creep boosts.
this.room.memory.canPerformReactions = false;
const labs = _.filter(this.room.myStructuresByType[STRUCTURE_LAB], structure => structure.isOperational());
- 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 calculateExpansionScore
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateExpansionScore(roomName: string) {
const result: ExpansionScore = {
score: 0,
reasons: {},
addScore(amount: number, reason: string) {
Function addClearingTerminalResourceOptions
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
addClearingTerminalResourceOptions(options: StorageSourceTask[], context: ResourceSourceContext) {
const storage = this.room.storage;
const terminal = this.room.terminal;
// Clear out overfull terminal.
- 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 addMilitaryAttackOptions
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
addMilitaryAttackOptions(creep: BrawlerCreep, options: MilitaryTargetOption[]) {
const enemies = creep.room.find(FIND_HOSTILE_CREEPS);
const targetPosition = decodePosition(creep.memory.target);
if (enemies && enemies.length > 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 generateRoomTerrainArray
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function generateRoomTerrainArray(roomName: string, bounds?: MinCutRect) {
if (!bounds) bounds = {x1: 0, y1: 0, x2: 49, y2: 49};
// Create two dimensional array of room tiles.
const roomArray = Array.from({length: 50}).fill(0).map(() => Array.from({length: 50}).fill(UNWALKABLE)) as number[][];
- 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 deleteTilesLeadingToDeadEnds
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
deleteTilesLeadingToDeadEnds(roomName: string, minCut: Array<{x: number; y: number}>) {
// Get terrain and set all cut-tiles as unwalkable.
const roomTerrain = generateRoomTerrainArray(roomName);
for (const tile of minCut) {
roomTerrain[tile.x][tile.y] = UNWALKABLE;
- 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 placeRamparts
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
placeRamparts(): StepResult {
// Make sure the controller can't directly be reached by enemies.
const roomIntel = getRoomIntel(this.roomName);
const safety = roomIntel.calculateAdjacentRoomSafety();
- 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 runTick
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
runTick() {
this.useMemoryFromHeap();
hivemind.segmentMemory.manage();
File brawler.ts
has 313 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RoomPosition MOVE ATTACK HEAL RANGED_ATTACK ATTACK_POWER
RANGED_ATTACK_POWER HEAL_POWER RESOURCE_ENERGY */
import BodyBuilder from 'creep/body-builder';
import cache from 'utils/cache';
File intershard.ts
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
import cache from 'utils/cache';
import hivemind from 'hivemind';
import interShard from 'intershard';
import NavMesh from 'utils/nav-mesh';
import Process from 'process/process';
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.
- 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 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).
- 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 render
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
PathFinder.CostMatrix.prototype.render = function (this: CostMatrix, roomName?: string, asVisual?: boolean): string {
const terrain = roomName && Game.map.getRoomTerrain(roomName);
const visual = roomName && asVisual && Game.rooms[roomName]?.visual;
let output = '<table style="display: inline-block">';
- 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 ensureBoostsHaveLabAssigned
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private ensureBoostsHaveLabAssigned(boosts: Partial<Record<ResourceConstant, number>>) {
const roomLabs = this.getAllLabs();
for (const resourceType in boosts) {
const assignedLab = _.find(roomLabs, lab => this.memory.labs[lab.id] === resourceType);
- 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"