Showing 899 of 1,362 total issues
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);
Function run
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
run() {
if (!hivemind.settings.get('enableTradeManagement')) return;
// Only trade if we have a terminal to trade with.
if (_.size(_.filter(Game.myRooms, room => room.terminal)) === 0) return;
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 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 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"
Further reading
File main.ts
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RawMemory */
// Make sure game object prototypes are enhanced.
import {ErrorMapper} from 'utils/ErrorMapper';
RoomManager
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
export default class RoomManager {
room: Room;
roomPlanner: RoomPlanner;
memory: RoomManagerMemory;
roomConstructionSites: ConstructionSite[];
Function performPickup
has 78 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 performMilitaryAttack
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
performMilitaryAttack(creep: BrawlerCreep) {
if (creep.memory.order) {
// Attack ordered target first.
const target = Game.getObjectById<Creep | AnyOwnedStructure>(creep.memory.order.target);
- 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 getBaseUpgraderAmount
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
getBaseUpgraderAmount(room: Room): number {
// Early on, builders will take care of upgrading once necessary
// structures have been built.
if (!room.storage && !room.terminal) return 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 getRegions
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
getRegions(exits: ExitInfo[]): RegionInfo[] {
this.exitLookup = {};
for (const exit of exits) {
this.exitLookup[exit.id] = exit;
}
- 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 addOptionsForTarget
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
addOptionsForTarget(info: PowerTargetRoom, roomName: string, sourceRoom: Room, options: PowerHarvesterSpawnOption[]) {
// We're assigned to spawn creeps for this power gathering operation!
const activePowerHarvesters = _.filter(Game.creepsByRole['harvester.power'] || [], (creep: Creep) => {
if (creep.memory.isHealer) return false;
if (creep.memory.sourceRoom !== sourceRoom.name) 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 isEnemyCloseToImportantStructures
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
isEnemyCloseToImportantStructures(): boolean {
for (const structure of this.getImportantStructures()) {
for (const userName in this.room.enemyCreeps) {
if (hivemind.relations.isAlly(userName)) 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 getRegions
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
getRegions(exits: ExitInfo[]): RegionInfo[] {
this.exitLookup = {};
for (const exit of exits) {
this.exitLookup[exit.id] = exit;
}
Function calculateAdjacentRoomSafety
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateAdjacentRoomSafety(options?: {safe?: string[]; unsafe?: string[]}): {directions: Record<string, boolean>; safeRooms: string[]} {
return cache.inHeap('adjacentSafety:' + this.roomName, 100, () => {
if (!this.memory.exits) {
return {
directions: {
Function getOntoCachedPath
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.getOntoCachedPath = function (this: Creep | PowerCreep) {
const creep = this;
const target = this.pos.findClosestByRange(this.getCachedPath(), {
filter: pos => {
// Try to move to a position on the path that is in the current room.
Function ensureRemoteHarvestContainerIsBuilt
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
ensureRemoteHarvestContainerIsBuilt(creep: MineBuilderCreep) {
if (!(creep.operation instanceof RemoteMiningOperation)) return false;
if ((creep.store.energy || 0) === 0) return false;
const workParts = creep.getActiveBodyparts(WORK) || 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 addRepairOptions
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
addRepairOptions(creep: BuilderCreep, options: OrderOption[]) {
const targets = _.filter(
this.getAvailableRepairTargets(creep),
structure => structure.hits < structure.hitsMax
&& !structure.needsDismantling()
- 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"