Showing 899 of 1,362 total issues
Function isCommodityNeededAtFactoryLevel
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function isCommodityNeededAtFactoryLevel(factoryLevel: number, resourceType: ResourceConstant): boolean {
for (const productType in COMMODITIES) {
const recipe = COMMODITIES[productType];
if (recipe.level && recipe.level !== factoryLevel) continue;
if (recipe.components[resourceType]) return true;
- 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 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 = {};
- 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 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;
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
run(creep: RelayHaulerCreep) {
if (!hivemind.segmentMemory.isReady()) return;
// @todo If empty, but there's no operation, return home and wait (or suicide).
- 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 getCreepBody
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getCreepBody(room: Room, option: UpgraderSpawnOption): BodyPartConstant[] {
const hasEasyEnergyAccess = room.memory.controllerContainer || room.memory.controllerLink;
return (new BodyBuilder())
.setWeights({[CARRY]: 1, [WORK]: hasEasyEnergyAccess ? 10 : 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 manage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
manage() {
if (!Memory.segmented) {
Memory.segmented = {
// Force saving data immediately so we don't have wrongly formatted
// old data in segment 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 consumer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static get consumer(): SourceMapConsumer {
if (this._consumer == null) {
let sourceMap;
try {
sourceMap = require('main.map.js');
- 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 getMaxWorkParts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getMaxWorkParts(source: Source): number {
let numberOfParts = source.energyCapacity / ENERGY_REGEN_TIME / 2;
_.each(source.effects, effect => {
if (effect.effect === PWR_REGEN_SOURCE) {
- 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 throttle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function throttle(offset: number, minBucket?: number, maxBucket?: number) {
initThrottleMemory();
if (!offset) offset = 0;
if (typeof minBucket !== 'number') minBucket = Memory.throttleInfo.bucket.critical;
- 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 needsDismantler
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
needsDismantler(sourceLocation?: string): boolean {
if (!hivemind.segmentMemory.isReady()) return false;
if (sourceLocation) return this.getDismantlePositions(sourceLocation).length > 0;
for (const pos of this.getSourcePositions()) {
- 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 addInitialHarvester
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addInitialHarvester(source: Source, options: HarvesterSpawnOption[]) {
// Spawn new harvester before previous harvester dies.
const spawns = _.filter(Game.spawns, spawn => spawn.room.name === source.room.name);
const minSpawnDistance = _.min(_.map(spawns, spawn => spawn.pos.getRangeTo(source.pos)));
const activeHarvesters = _.filter(source.harvesters, creep => creep.spawning || creep.ticksToLive > creep.body.length * CREEP_SPAWN_TIME + minSpawnDistance);
- 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 getUpgraderAmount
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getUpgraderAmount(room: Room): number {
const maxUpgraders = this.getBaseUpgraderAmount(room);
if (maxUpgraders === 0) {
// Even if no upgraders are needed, at least create one when the controller is getting close to being downgraded.
- 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 migrateData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
migrateData() {
// Move room intel into segment memory.
if (!this.memory.intelMigrated) {
if (!this.segmentMemory.isReady()) return true;
- 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 addEmergencyRepairSpawnOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addEmergencyRepairSpawnOptions(room: Room, options: RoomDefenseSpawnOption[]) {
if (room.controller.level < 4) return;
if (!room.memory.enemies || room.memory.enemies.safe) return;
if (room.getEffectiveAvailableEnergy() < 10_000) 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 constructor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
constructor(channel: string, roomName?: string) {
this.channel = channel;
this.channelName = (' ' + this.channel).slice(-10);
this.color = channels.default.color;
this.roomName = 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 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 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 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"