File prototype_room_creepbuilder.js
has 447 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
const {
CreepPartData,
sortCreepParts,
Function prepareBoosting
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function prepareBoosting(room, creep, config) {
if (!room.terminal || !room.terminal.my) {
return 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"
Further reading
Function getPartConfig
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.getPartConfig = function(creep) {
// TODO this needs to be rethought and rebuild (more simple)
let energyAvailable = this.energyAvailable;
const settings = this.getSettings(creep);
const {
Function stringToParts
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function stringToParts(stringParts) {
if (!stringParts || typeof (stringParts) !== 'string') {
return undefined;
}
const arrayParts = [];
Function getPartConfig
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.getPartConfig = function(creep) {
// TODO this needs to be rethought and rebuild (more simple)
let energyAvailable = this.energyAvailable;
const settings = this.getSettings(creep);
const {
- 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 getCreepConfig
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.getCreepConfig = function(creep) {
const role = creep.role;
const unit = roles[role];
if (!unit) {
this.log('Can not find role: ' + role + ' creep_' + role);
Function prepareBoosting
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function prepareBoosting(room, creep, config) {
if (!room.terminal || !room.terminal.my) {
return false;
}
Function checkRoleToSpawn
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.checkRoleToSpawn = function(role, amount, targetId, targetRoom, level, base, additionalMemory = {}) {
const creepMemory = this.creepMem(role, targetId, targetRoom, level, base);
Object.assign(creepMemory, additionalMemory);
if (this.inQueue(creepMemory) || this.inRoom(creepMemory, amount)) {
return 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"
Further reading
Function checkRoleToSpawn
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Room.prototype.checkRoleToSpawn = function(role, amount, targetId, targetRoom, level, base, additionalMemory = {}) {
Avoid deeply nested control flow statements. Open
if (room.terminal.store[mineral] > 30) {
boostConfig.resources.push(mineral);
}
Function creepMem
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Room.prototype.creepMem = function(role, targetId, targetRoom, level, base) {
Function spawnCreateCreep
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.spawnCreateCreep = function(creep) {
const spawns = this.findSpawnsNotSpawning();
if (spawns.length === 0) {
return 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"
Further reading
Avoid too many return
statements within this function. Open
return true;
Function inRoom
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.inRoom = function(creepMemory, amount = 1) {
if (amount === 0) {
return false;
}
const creepsSpawning = this.getSpawningCreeps();
- 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"