Function pickupResources
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
pickupResources(creep: MuleCreep) {
const originRoom = this.tradeRoute.getOrigin();
if (creep.pos.roomName !== originRoom) {
// Move back to spawn room.
this.followRoomPath(creep);
Function pickupResources
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
pickupResources(creep: MuleCreep) {
const originRoom = this.tradeRoute.getOrigin();
if (creep.pos.roomName !== originRoom) {
// Move back to spawn room.
this.followRoomPath(creep);
- 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 followRoomPath
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
followRoomPath(creep: MuleCreep) {
if (!creep.memory.roomPath) {
const targetPosition = new RoomPosition(25, 25, creep.memory.delivering ? this.tradeRoute.getTarget() : this.tradeRoute.getOrigin());
creep.interRoomTravel(targetPosition);
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 deliverResources
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
deliverResources(creep: MuleCreep) {
// @todo If delivering energy to one of our own rooms that doesn't have
// a storage, use transporter logic to drop off the energy, or even
// act as a temporary container until energy is used up.
const targetRoom = this.tradeRoute.getTarget();
- 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;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
if (!target) return;