Function getMatrixCallback
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.getMatrixCallback = function(end) {
// TODO cache?!
const callback = (roomName) => {
const room = Game.rooms[roomName];
const costMatrix = new PathFinder.CostMatrix();
- 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 buildPath
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.buildPath = function(route, routePos, from, to) {
if (!to) {
throw new Error();
}
let start;
Function setSources
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function setSources(costMatrix, room, end) {
const sources = room.find(FIND_SOURCES, {
filter: (object) => {
return !end || object.pos.x !== end.x || object.pos.y !== end.y;
},
- 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 buildPath
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.buildPath = function(route, routePos, from, to) {
if (!to) {
throw new Error();
}
let start;
- 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 routeCallbackRoomHandle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function routeCallbackRoomHandle(roomName) {
let returnValue;
if (Memory.rooms[roomName].state === 'Occupied') {
// console.log(Game.time, `Creep.prototype.getRoute: Do not route through occupied rooms ${roomName}`);
if (config.path.allowRoutingThroughFriendRooms && friends.indexOf(Memory.rooms[roomName].player) > -1) {
- 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 getCreepPositionForId
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.getCreepPositionForId = function(to) {
if (this.data.positions.creep[to]) {
const pos = this.data.positions.creep[to][0];
if (pos) {
return new RoomPosition(pos.x, pos.y, this.name);
- 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"