Function siege
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.siege = function() {
this.memory.hitsLost = this.memory.hitsLast - this.hits;
// This is the same as `lastHits`, except of the execution time, maybe both can be combined
this.memory.hitsLast = this.hits;
Function siege
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.siege = function() {
this.memory.hitsLost = this.memory.hitsLast - this.hits;
// This is the same as `lastHits`, except of the execution time, maybe both can be combined
this.memory.hitsLast = this.hits;
- 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 fightRampart
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.fightRampart = function(target) {
if (!target) {
return false;
}
Function fightRampart
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.fightRampart = function(target) {
if (!target) {
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;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return true;
Function fleeFromHostile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.fleeFromHostile = function(hostile) {
let direction = RoomPosition.oppositeDirection(this.pos.getDirectionTo(hostile));
if (!direction || direction === null || this.pos.isBorder(-1)) {
this.moveTo(25, 25);
return true;
- 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 handleDefender
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.handleDefender = function() {
const hostile = this.findClosestEnemy();
if (this.fightRampart(hostile)) {
return true;
- 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"