Showing 886 of 1,349 total issues
Function run
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
run(creep: BuilderCreep) {
if (creep.heapMemory.suicideSpawn) {
this.performRecycle(creep);
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 addContainerResourceOptions
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
addContainerResourceOptions(options: TransporterSourceOrderOption[]) {
const room = this.creep.room;
// We need a decent place to store these resources.
if (!room.terminal && !room.storage) 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 getPathFor
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
getPathFor(sourcePosition: RoomPosition): RoomPosition[] | null {
if (!hivemind.segmentMemory.isReady()) return null;
const key = 'remotePath:' + encodePosition(sourcePosition);
if (!hivemind.segmentMemory.has(key)) {
- 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 20 (exceeds 5 allowed). Consider refactoring. Open
run(): StepResult {
// @todo Make sure tower access roads are always behind ramparts!
let towerCount = 0;
const positions = this.findTowerPositions();
- 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 addLabResourceOptions
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
addLabResourceOptions(options: LabSourceTask[], context: ResourceSourceContext) {
const room = this.room;
const currentReaction = room.memory.currentReaction;
if (!room.memory.canPerformReactions) return;
Function checkClaimPath
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkClaimPath() {
const info = this.memory.currentTarget;
if (!info) return;
const room = Game.rooms[info.roomName];
Function goTo
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.goTo = function (this: Creep | PowerCreep, target: RoomObject | RoomPosition, options: GoToOptions) {
if (!target) return false;
if (!options) options = {};
container.get('TrafficManager').setMoving(this);
RemoteMiningSpawnRole
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export default class RemoteMiningSpawnRole extends SpawnRole {
/**
* Adds claimer spawn options for the given room.
*
* @param {Room} room
Function calculateRoomPath
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.calculateRoomPath = function (targetRoom: string, options) {
const roomName = this.name;
if (!options) options = {};
Function moveUsingNavMesh
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.moveUsingNavMesh = function (this: Creep | PowerCreep, targetPos, options) {
if (!hivemind.segmentMemory.isReady()) return OK;
if (!options) options = {};
Function run
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
run(creep: RemoteBuilderCreep) {
this.creep = creep;
if (creep.memory.interShardPortal) {
const targetPos = decodePosition(creep.memory.interShardPortal);
- 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 performOperationDismantle
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
performOperationDismantle(creep: DismantlerCreep): boolean {
if (!creep.operation) return false;
if (!(creep.operation instanceof RemoteMiningOperation)) return false;
if (!creep.heapMemory.finishedPositions) creep.heapMemory.finishedPositions = [];
- 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 performSkSlaughter
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
performSkSlaughter(creep: SkKillerCreep) {
if (creep.pos.roomName !== creep.operation.getRoom()) return;
creep.memory.singleRoom = creep.operation.getRoom();
const sourceKeepers = [];
- 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 getRemoteDefenseSpawnOptions
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
getRemoteDefenseSpawnOptions(room: Room, options: BrawlerSpawnOption[]) {
if (room.getEffectiveAvailableEnergy() < 5_000) return;
const harvestPositions: RoomPosition[] = room.getRemoteHarvestSourcePositions();
for (const pos of harvestPositions) {
- 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 handleRequests
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
handleRequests() {
for (const request of simpleAllies.allySegmentData?.requests?.funnel ?? []) {
if (!Memory.requests.trade[RESOURCE_ENERGY]) {
Memory.requests.trade[RESOURCE_ENERGY] = {};
}
- 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 manageStructures
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
manageStructures() {
if (_.size(Game.spawns) === 1 && _.sample(Game.spawns).room.name === this.room.name && this.room.controller.level < 4) {
// In our first room, getting more extensions is pretty important for
// spawning bigger creeps asap.
this.manageExtensions();
- 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 instaBuyResources
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
instaBuyResources(resourceType: TradeResource, rooms?: Record<string, RoomResourceState>, force?: boolean) {
// Find room with lowest amount of this resource.
const roomName = isIntershardResource(resourceType) ? null : this.getRoomLowestOn(resourceType, rooms);
if (!roomName && !isIntershardResource(resourceType)) 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
File cost-matrix.ts
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
import cache from 'utils/cache';
import hivemind from 'hivemind';
import {encodePosition} from 'utils/serialization';
import {ENEMY_STRENGTH_NONE} from 'room-defense';
import {getRoomIntel} from 'room-intel';
Function run
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
run() {
const manager = container.get('TradeRouteManager');
let routes = manager.getAvailableTransportRoutes();
let best = utilities.getBestOption(routes);
Function performGetResources
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
performGetResources(sourceCallback?: () => void) {
const creep = this.creep;
if (!sourceCallback) {
sourceCallback = () => {
this.calculateSource();