Showing 900 of 1,365 total issues
Function manageTowers
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
manageTowers() {
const towers = _.filter(this.room.myStructuresByType[STRUCTURE_TOWER], s => s.energy > 0);
if (towers.length === 0) 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 checkClaimPath
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
checkClaimPath() {
const info = this.memory.currentTarget;
if (!info) return;
const room = Game.rooms[info.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
File operator.ts
has 421 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RoomPosition OK POWER_INFO PWR_GENERATE_OPS PWR_REGEN_SOURCE
PWR_OPERATE_STORAGE PWR_OPERATE_SPAWN RESOURCE_OPS STORAGE_CAPACITY
STRUCTURE_SPAWN PWR_OPERATE_EXTENSION RESOURCE_ENERGY
PWR_REGEN_MINERAL POWER_CREEP_LIFE_TIME PWR_OPERATE_TOWER */
File remote-mining.ts
has 421 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global MOVE CLAIM BODYPART_COST CONTROLLER_RESERVE_MAX RESOURCE_ENERGY */
import BodyBuilder from 'creep/body-builder';
import hivemind from 'hivemind';
import settings from 'settings-manager';
Function calculateRoomPath
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.calculateRoomPath = function (targetRoom: string, options) {
const roomName = this.name;
if (!options) options = {};
- 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 getResourceLevelCutoffs
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.getResourceLevelCutoffs = function (this: Room, resourceType: ResourceConstant): ResourceLevelCuttoffs {
if (resourceType === RESOURCE_ENERGY) {
// Defending rooms need energy to defend.
if (this.defense.getEnemyStrength() >= ENEMY_STRENGTH_NORMAL) return [1_000_000, 100_000, 50_000];
- 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 trade.ts
has 413 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RESOURCES_ALL RESOURCE_ENERGY RESOURCE_POWER OK RESOURCE_OPS
ORDER_BUY ORDER_SELL PIXEL STORAGE_CAPACITY INTERSHARD_RESOURCES
REACTION_TIME */
import cache from 'utils/cache';
Function run
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
run() {
const manager = container.get('TradeRouteManager');
let routes = manager.getAvailableTransportRoutes();
let best = utilities.getBestOption(routes);
- 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 scout.ts
has 398 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RoomPosition OBSERVER_RANGE SOURCE_ENERGY_CAPACITY */
import Process from 'process/process';
import hivemind from 'hivemind';
import interShard from 'intershard';
RoomIntel
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
export default class RoomIntel {
roomName: string;
memory: RoomIntelMemory;
newStatus: Record<string, boolean>;
File builder.ts
has 395 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global FIND_STRUCTURES FIND_MY_CONSTRUCTION_SITES STRUCTURE_SPAWN OK
STRUCTURE_RAMPART STRUCTURE_WALL STRUCTURE_ROAD STRUCTURE_CONTAINER WORK
UPGRADE_CONTROLLER_POWER RESOURCE_ENERGY */
import balancer from 'excess-energy-balancer';
Function buildRoadOnCachedPath
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
buildRoadOnCachedPath(creep: MineBuilderCreep) {
// Don't try to build roads in rooms owned by other players.
if (creep.room.controller && creep.room.controller.owner && !creep.room.isMine()) return false;
const workParts = creep.getActiveBodyparts(WORK);
- 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 addObjectEnergySourceOptions
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
addObjectEnergySourceOptions(options: TransporterSourceOrderOption[], findConstant: FIND_RUINS | FIND_TOMBSTONES | FIND_DROPPED_RESOURCES, optionType: 'resource' | 'tombstone', storagePriority: number) {
const creep = this.creep;
// Get storage location, since that is a low priority source for transporters.
const storagePosition = creep.room.getStorageLocation();
- 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 remote-mining.ts
has 379 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RoomPosition SOURCE_ENERGY_CAPACITY CARRY_CAPACITY
SOURCE_ENERGY_NEUTRAL_CAPACITY ENERGY_REGEN_TIME CONTROLLER_RESERVE_MAX
HARVEST_POWER LOOK_STRUCTURES STRUCTURE_CONTAINER */
import cache from 'utils/cache';
Function addLabResourceOptions
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
addLabResourceOptions(options: LabSourceTask[], context: ResourceSourceContext) {
const room = this.room;
const currentReaction = room.memory.currentReaction;
if (!room.memory.canPerformReactions) 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 addContainerEnergySourceOptions
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
private addContainerEnergySourceOptions(options: ContainerSourceTask[], context: ResourceSourceContext) {
const creep = context.creep;
if (context.resourceType && context.resourceType !== RESOURCE_ENERGY) return;
// Look for energy in Containers.
- 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 mincut.ts
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global TERRAIN_MASK_WALL */
/**
* Code for calculating the minCut in a room.
* Based on code written by Saruss and adapted by Chobobobo.
Function moveUsingNavMesh
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.moveUsingNavMesh = function (this: Creep | PowerCreep, targetPos, options) {
if (!hivemind.segmentMemory.isReady()) return OK;
if (!options) options = {};
- 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 goTo
has a Cognitive Complexity of 33 (exceeds 5 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);
- 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 cleanup
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
cleanup() {
// Periodically clean creep memory.
if (Game.time % 16 === 7) {
for (const name in Memory.creeps) {
if (!Game.creeps[name]) {
- 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"