Function cleanCreeps
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function cleanCreeps() {
// Cleanup memory
if (!Memory.creeps) {
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 cleanRooms
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function cleanRooms() {
if (Game.time % 300 === 0) {
for (const name of Object.keys(Memory.rooms)) {
// TODO lastSeen moved to global.data - so we should check this, also Memory.rooms should only exist for myRooms
if (!Memory.rooms[name].lastSeen && Object.keys(Memory.rooms[name]).length > 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
Function handleUnexpectedDeadCreeps
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleUnexpectedDeadCreeps(name, creepMemory) {
let data;
if (creepMemory.room) {
data = global.data.rooms[creepMemory.room];
} else {
Function printSummary
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function printSummary() {
const interval = 100;
if (Game.time % interval !== 0) {
return;
}
Function handleUnexpectedDeadCreeps
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function handleUnexpectedDeadCreeps(name, creepMemory) {
let data;
if (creepMemory.room) {
data = global.data.rooms[creepMemory.room];
} else {
- 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 setConstructionSites
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function setConstructionSites() {
if (!Memory.constructionSites) {
Memory.constructionSites = {};
}
- 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 cleanCreeps
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cleanCreeps() {
// Cleanup memory
if (!Memory.creeps) {
return;
}
Function cleanSquads
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function cleanSquads() {
if (Game.time % 1500 === 0) {
for (const squadId of Object.keys(Memory.squads)) {
const squad = Memory.squads[squadId];
if (Game.time - squad.born > 3000) {
- 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"