Showing 899 of 1,362 total issues
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
else return;
Avoid too many return
statements within this function. Open
return true;
Function isValid
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
isValid(task: TaskType, context: ResourceDestinationContext) {
const structure = Game.getObjectById(task.target);
if (!structure) return false;
if (!structure.isOperational()) return false;
if (context.creep.memory.singleRoom && structure.pos.roomName !== context.creep.memory.singleRoom) return false;
- 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 getMissingComponents
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getMissingComponents(): Partial<Record<FactoryComponentConstant, number>> | null {
const requestedResources = this.getRequestedComponents();
const result: Partial<Record<FactoryComponentConstant, number>> = {};
let hasNeed = false;
- 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 gatherControllerIntel
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
gatherControllerIntel(room: Room) {
this.memory.owner = null;
this.memory.rcl = 0;
this.memory.ticksToDowngrade = 0;
this.memory.hasController = typeof room.controller !== 'undefined';
- 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 gatherPortalIntel
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
gatherPortalIntel(portals: StructurePortal[]) {
delete this.memory.portals;
const targetRooms: string[] = [];
for (const portal of portals || []) {
- 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 addResourcesForSaleDestination
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addResourcesForSaleDestination(options: TerminalDestinationTask[], context: ResourceDestinationContext) {
const terminal = this.room.terminal;
const roomSellOrders = _.filter(Game.market.orders, order => order.roomName === this.room.name && order.type === ORDER_SELL);
for (const order of roomSellOrders) {
- 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 performUpgrade
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
performUpgrade(creep: BuilderCreep) {
if (
creep.room.roomManager?.hasMisplacedSpawn()
|| (creep.room.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL && !creep.room.controller?.safeMode)
|| creep.room.find(FIND_MY_CONSTRUCTION_SITES).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 usePower
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
usePower() {
const order = this.creep.memory.order as OperatorUsePowerOrder;
const power = order.power;
const powerInfo = POWER_INFO[power];
const range = 'range' in powerInfo ? powerInfo.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 performDeliver
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
performDeliver(creep: DepositHarvesterCreep) {
const origin = creep.memory.origin;
if (!Game.rooms[origin] || !Game.rooms[origin].isMine()) {
// @todo Choose a new room close by and deliver.
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 isOscillating
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
isOscillating(creep: ScoutCreep) {
if (!creep.heapMemory.roomHistory) creep.heapMemory.roomHistory = [];
const history = creep.heapMemory.roomHistory;
if (history.length === 0 || history[history.length - 1] !== creep.pos.roomName) history.push(creep.pos.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 repairNearbyContainer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
repairNearbyContainer(creep: RemoteHarvesterCreep): boolean {
const workParts = creep.getActiveBodyparts(CARRY) ? creep.getActiveBodyparts(WORK) : 0;
if (workParts === 0) return false;
if (creep.store.energy < workParts) return false;
- 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 getAdjacentRampartPositions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getAdjacentRampartPositions(creep: GuardianCreep): RoomPosition[] {
const closestRamparts = _.filter(
creep.room.myStructuresByType[STRUCTURE_RAMPART],
s => {
if (s.pos.getRangeTo(creep.pos) !== 1) return false;
- 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 mayCurrentOrderBeInterrupted
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
mayCurrentOrderBeInterrupted(): boolean {
const order = this.creep.memory.order;
if (!order) return true;
if (order.type === 'performRenew') return false;
if (!('target' in order)) 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 getNextBodyPart
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private getNextBodyPart(partCounts: PartCounts): BodyPartConstant {
const currentWeights = this.normalizeWeights(partCounts);
let fallbackPart: BodyPartConstant = null;
for (const part of (_.keys(this.weights) as BodyPartConstant[])) {
- 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 generateTileCache
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private generateTileCache(pos: RoomPosition, encodedPos: string) {
if (this.tileCacheTime !== Game.time) {
this.tileCache = {};
this.tileCacheTime = Game.time;
}
- 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 isBayExtension
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
StructureExtension.prototype.isBayExtension = function () {
if (!this.bayChecked) {
this.bayChecked = true;
this.bay = 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
Function transferAny
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.transferAny = function (this: Creep, target: Structure): ScreepsReturnCode {
for (const resourceType of getResourcesIn(this.store)) {
if (target.structureType === STRUCTURE_LINK && resourceType !== RESOURCE_ENERGY) continue;
if (this.store[resourceType] > 0) {
return this.transfer(target, 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"
Further reading
Function couldWinFightAgainst
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public couldWinFightAgainst(creep: Creep, otherCreep: Creep): boolean {
if (
(
creep.getActiveBodyparts(RANGED_ATTACK) > 0
|| (creep.getActiveBodyparts(ATTACK) > 0 && otherCreep.getActiveBodyparts(RANGED_ATTACK) === 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"