Showing 886 of 1,349 total issues
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>;
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 builder.ts
has 391 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';
File room.resources.ts
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global Room RoomPosition RESOURCE_ENERGY LOOK_RESOURCES
RESOURCE_POWER STRUCTURE_LAB RESOURCES_ALL */
import cache from 'utils/cache';
import container from 'utils/container';
File remote-mining.ts
has 381 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 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
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
File hauler.relay.ts
has 376 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global FIND_DROPPED_RESOURCES RESOURCE_ENERGY OK LOOK_CONSTRUCTION_SITES
ERR_NO_PATH ERR_NOT_IN_RANGE STRUCTURE_CONTAINER STRUCTURE_ROAD
FIND_MY_CONSTRUCTION_SITES LOOK_STRUCTURES MAX_CONSTRUCTION_SITES */
// @todo Collect energy if it's lying on the path.
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 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 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
File combat-manager.ts
has 367 lines of code (exceeds 250 allowed). Consider refactoring. Open
import cache from 'utils/cache';
import hivemind from 'hivemind';
import utilities from 'utilities';
import {getResourcesIn} from 'utils/store';
import {handleMapArea} from 'utils/map';
Function addConnectingPathsForRegion
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
addConnectingPathsForRegion(region: RegionInfo, paths: Record<number, Record<number, number>>, roomName: string, costMatrix: CostMatrix) {
const centerXR = region.center % 50;
const centerYR = Math.floor(region.center / 50);
for (const exitId of region.exits) {
- 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 addHarvesterOptionForPosition
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
addHarvesterOptionForPosition(room: Room, position: RoomPosition, options: RemoteMiningSpawnOption[]) {
const targetPos = encodePosition(position);
const operation = Game.operationsByType.mining['mine:' + position.roomName];
// Don't spawn if enemies are in the room.
- 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
RoomVariationBuilder
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
export default class RoomVariationBuilder extends RoomVariationBuilderBase {
exitCenters: ExitCoords;
roomCenter: RoomPosition;
roomCenterEntrances: RoomPosition[];
safetyMatrix: CostMatrix;
Function run
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
run(creep: PowerHaulerCreep) {
if (!creep.memory.isReturning && (creep.store.getFreeCapacity() === 0 || (creep.store.power || 0) > creep.store.getCapacity() / 10)) {
// Return home.
creep.memory.isReturning = true;
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 followCachedPath
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.followCachedPath = function (this: Creep | PowerCreep) {
drawCreepMovement(this);
container.get('TrafficManager').setMoving(this);
this.heapMemory._moveBlocked = 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"