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';
RemoteMiningOperation
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
export default class RemoteMiningOperation extends Operation {
protected memory: RemoteMiningOperationMemory;
protected pathManager: PathManager;
/**
Function getDismantlePositions
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
getDismantlePositions(sourceLocation: string): RoomPosition[] {
if (!hivemind.segmentMemory.isReady()) return [];
// No dismantlers for SK rooms, they get confused easily...
const roomIntel = getRoomIntel(this.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
Function getPaths
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPaths() {
return cache.inObject(this, 'getPaths', 0, () => {
if (!hivemind.segmentMemory.isReady()) return {};
const roomIntel = getRoomIntel(this.roomName);
Function getDismantlePositions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
getDismantlePositions(sourceLocation: string): RoomPosition[] {
if (!hivemind.segmentMemory.isReady()) return [];
// No dismantlers for SK rooms, they get confused easily...
const roomIntel = getRoomIntel(this.roomName);
Function getTotalEnemyData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getTotalEnemyData(): EnemyData {
const totalEnemyData: EnemyData = {
parts: {},
damage: 0,
heal: 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
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
if (!containerPosition) return false;
Avoid too many return
statements within this function. Open
return false;
Function needsDismantler
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
needsDismantler(sourceLocation?: string): boolean {
if (!hivemind.segmentMemory.isReady()) return false;
if (sourceLocation) return this.getDismantlePositions(sourceLocation).length > 0;
for (const pos of this.getSourcePositions()) {
- 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"