Showing 886 of 1,349 total issues
Function totalTime
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const totalTime = timeCall('operation:' + operationName, () => {
hivemind.runSubProcess('rooms_roomplanner', () => {
// RoomPlanner has its own 100 tick throttling, so we runLogic every tick.
if (this.room.roomPlanner) this.room.roomPlanner.runLogic();
});
Function performMilitaryMove
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
performMilitaryMove(creep: BrawlerCreep) {
if (creep.isPartOfTrain() && this.performTrainMove(creep) !== OK) return;
if (creep.memory.fillWithEnergy) {
if (creep.room.isMine() && creep.store.getFreeCapacity() > 0) {
Function saveExpiringRamparts
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
saveExpiringRamparts(minHits: number): boolean {
if (!this.creep.memory.repairTarget) {
// Make sure ramparts don't break.
const ramparts = _.filter(
this.creep.room.structuresByType[STRUCTURE_RAMPART],
- 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 18 (exceeds 5 allowed). Consider refactoring. Open
performUpgrade(creep: UpgraderCreep, allowRefilling: boolean) {
// Upgrade controller.
const controller = creep.room.controller;
const distance = creep.pos.getRangeTo(controller);
const isOnlyUpgrader = creep.memory.role === 'upgrader' && _.size(creep.room.creepsByRole.upgrader) === 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 findHostiles
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
findHostiles() {
const parts = {};
let lastSeen = this.room.memory.enemies ? this.room.memory.enemies.lastSeen : 0;
let expires = null;
let safe = 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 removeMisplacedSpawn
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
removeMisplacedSpawn(roomSpawns: StructureSpawn[]) {
for (const spawn of roomSpawns) {
if (this.roomPlanner.isPlannedLocation(spawn.pos, 'spawn')) continue;
// Only destroy spawn if there are enough resources and builders available.
- 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 pruneWalls
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
pruneWalls(walls: RoomPosition[]) {
const roomIntel = getRoomIntel(this.roomName);
const safety = roomIntel.calculateAdjacentRoomSafety();
const roomCenter = _.first(this.roomPlan.getPositions('center'));
this.safetyMatrix = new PathFinder.CostMatrix();
- 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 placeDecorativeWalls
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
placeDecorativeWalls(): StepResult {
const patternHeight = decorativeWallPattern.length;
const patternWidth = decorativeWallPattern[0].length;
for (let x = 1; x < 49; x++) {
- 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 performRemoteHarvest
has 60 lines of code (exceeds 25 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.
Function performGetRemoteBuilderEnergy
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
performGetRemoteBuilderEnergy() {
// @todo Switch to using priority list to determine where to get energy.
const creep = this.creep;
// Move to source room if necessary.
Function followCachedPath
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.followCachedPath = function (this: Creep | PowerCreep) {
drawCreepMovement(this);
container.get('TrafficManager').setMoving(this);
this.heapMemory._moveBlocked = false;
NavMesh
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export default class NavMesh {
memory: NavMemory;
terrain: RoomTerrain;
costMatrix: CostMatrix;
exitLookup: Record<number, ExitInfo>;
BoostManager
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export default class BoostManager {
memory: BoostManagerMemory;
room: Room;
public constructor(room: Room) {
TradeProcess
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export default class TradeProcess extends Process {
availableCredits: number;
/**
* Buys and sells resources on the global market.
Function addMilitaryAttackOptions
has 58 lines of code (exceeds 25 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) {
Function run
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
run() {
// @todo Add throttle like with remote harvesting.
const memory = Memory.strategy.power;
this.mesh = new NavMesh();
Function depositResources
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
depositResources(creep: HarvesterCreep, source: Source | Mineral) {
const harvestPower = (source instanceof Source) ? HARVEST_POWER : HARVEST_MINERAL_POWER;
if (creep.store.getFreeCapacity() >= creep.getActiveBodyparts(WORK) * harvestPower) return;
const targetContainer = source.getNearbyContainer();
Function joinTrain
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.joinTrain = function (this: Creep) {
const segments = this.getTrainParts();
let canMoveBack = true;
for (let i = 1; i < segments.length; i++) {
- 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 getNearbyTargets
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private getNearbyTargets(creep: Creep): AttackTarget[] {
const availableTargets: AttackTarget[] = [];
const maxRange = this.getMaxAttackRange(creep);
for (const enemyName in creep.room.enemyCreeps) {
- 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 trySpawnCreep
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
trySpawnCreep(room: Room, spawn: StructureSpawn, option): boolean {
const role = this.roles[option.role];
const body = role.getCreepBody(room, option);
if (!body || body.length === 0) 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"