Showing 492 of 594 total issues
Function getEnergyFromStorage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.getEnergyFromStorage = function() {
if (!this.room.storage) {
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 inLayer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const inLayer = function(room, pos) {
for (let i = 0; i < room.memory.walls.layer_i; i++) {
for (const j of Object.keys(room.memory.walls.layer[i])) {
const position = room.memory.walls.layer[i][j];
if (pos.isEqualTo(position.x, position.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 getQuestData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function getQuestData(room) {
const sign = room.controller.sign;
let data;
try {
data = JSON.parse(sign.text);
- 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 preMove
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
roles.structurer.preMove = function(creep, directions) {
creep.creepLog(`preMove: targetId: ${creep.memory.routing.targetId}`);
preMoveTargetRoom(creep, directions);
// Routing would end within the wall - this is the fix for that
- 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 action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
roles.upgrader.action = function(creep) {
creep.mySignController();
creep.spawnReplacement(1);
if (!creep.room.controller.isAboutToDowngrade()) {
if (creep.room.isUnderAttack()) {
- 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 generatePixel
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function generatePixel() {
if (global.config.pixel.enabled) {
if (typeof PIXEL !== 'undefined') {
if (Game.cpu.bucket >= PIXEL_CPU_COST + global.config.pixel.minBucketAfter) {
Game.cpu.generatePixel();
- 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 checkSourcer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.checkSourcer = function() {
const sources = this.findSources();
const sourcers = this.findSourcer();
for (const source of sources) {
- 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 action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
roles.defendmelee.action = function(creep) {
const hostile = creep.findClosestEnemy();
if (hostile === null) {
if (creep.room.memory.attackTimer % 3 === 0) {
return Creep.recycleCreep(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 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"
Further reading
Function addToQueue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function addToQueue(spawns, roomNameFrom, roomNameTarget, squadName, queueLimit) {
queueLimit = queueLimit || false;
const outer = function(spawn) {
return function _addToQueue() {
if (queueLimit === 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 isFriend
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
module.exports.isFriend = function(name) {
if (!Memory.players) {
Memory.players = {};
}
- 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 checkWrongStructure
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.checkWrongStructure = function() {
this.debugLog('baseBuilding', 'checkWrongStructure: ' + this.memory.controllerLevel.checkWrongStructureInterval);
if (this.memory.underSiege && this.controller.level >= 3) {
this.log('checkWrongStructure: underSiege');
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 setupStructureFinishPriorityStructures
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function setupStructureFinishPriorityStructures(structure, constructionSites) {
// Only build one spawn at a time, especially for reviving
if (structure === STRUCTURE_SPAWN) {
if (constructionSites.length > 0) {
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 energyAcceptingLink
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const energyAcceptingLink = function(object, room) {
if (object.structureType === STRUCTURE_LINK) {
for (let i = 0; i < 3; i++) {
const linkPos = room.data.positions.structure.link[i];
if (object.pos.isEqualTo(linkPos.x, linkPos.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 transferEnergy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.transferEnergy = function() {
const target = this.getTransferTarget();
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
Function inPath
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
RoomPosition.prototype.inPath = function() {
const room = this.getRoom();
for (const pathName of Object.keys(room.getMemoryPaths())) {
const path = room.getMemoryPath(pathName);
for (const pos of path) {
- 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 withdrawResourcesFromTargets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.withdrawResourcesFromTargets = function(targets, onlyEnergy) {
let returnValue = false;
for (const target of targets) {
if (!returnValue) {
returnValue = onlyEnergy ? this.withdrawEnergyFromTarget(target) : this.withdrawResourcesFromTarget(target);
- 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 giveSourcersEnergy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.giveSourcersEnergy = function() {
let returnValue = false;
const sourcers = this.pos.findInRangeSourcer(1);
if (sourcers.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 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"