Function addAdditionalHarvesters
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
addAdditionalHarvesters(source: Source, options: HarvesterSpawnOption[]) {
// Starting from RCL 4, 1 harvester per source should always be enough.
if (source.room.controller.level > 3) return;
// Don't spawn more harvesters than we have space for.
- 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 getMaxWorkParts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
getMaxWorkParts(source: Source): number {
let numberOfParts = source.energyCapacity / ENERGY_REGEN_TIME / 2;
_.each(source.effects, effect => {
if (effect.effect === PWR_REGEN_SOURCE) {
- 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 addInitialHarvester
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
addInitialHarvester(source: Source, options: HarvesterSpawnOption[]) {
// Spawn new harvester before previous harvester dies.
const spawns = _.filter(Game.spawns, spawn => spawn.room.name === source.room.name);
const minSpawnDistance = _.min(_.map(spawns, spawn => spawn.pos.getRangeTo(source.pos)));
const activeHarvesters = _.filter(source.harvesters, creep => creep.spawning || creep.ticksToLive > creep.body.length * CREEP_SPAWN_TIME + minSpawnDistance);
- 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"