Showing 886 of 1,349 total issues
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) {
File intershard.ts
has 318 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 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 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 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 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();
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 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"
Further reading
Function run
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
run() {
const operationName = 'room:' + this.room.name;
let operation = Game.operationsByType.room[operationName];
if (!operation) {
operation = new RoomOperation(operationName);
File brawler.ts
has 306 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';
OperatorRole
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
export default class OperatorRole extends Role {
creep: PowerCreep;
/**
* Makes a power creep behave like an operator.
Function performPickup
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
performPickup(creep: RelayHaulerCreep) {
creep.say('p0');
const sourcePosition = decodePosition(creep.memory.source);
if (!sourcePosition) {
creep.say('newtar');
Function performRemoteHarvest
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
performRemoteHarvest(creep: RemoteHarvesterCreep) {
if (creep.pos.roomName !== creep.operation.getRoom()) return;
// Check if a container nearby is in need of repairs, since we can handle
// it with less intents than haulers do.
- 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 attackMilitaryTarget
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
attackMilitaryTarget(creep: BrawlerCreep, target: Creep | AnyStructure) {
if (target instanceof StructureController) {
if (target.owner && creep.attackController(target) === OK) {
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 getStoredEnergy
has a Cognitive Complexity of 23 (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 getDamageCapacity
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.getDamageCapacity = function (this: Creep, range) {
// @todo Cache for one tick?
let total = 0;
if (range > 3) return total;
- 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 addClaimerSpawnOptions
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
addClaimerSpawnOptions(room: Room, options: RemoteMiningSpawnOption[]) {
if (options.length > 0) return;
// Only spawn claimers if they can have 2 or more claim parts.
// @todo We could even do it with 1 part if the controller has multiple
- 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"