Showing 492 of 594 total issues
Function checkPlayers
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function checkPlayers() {
if (Game.time % config.diplomacy.checkPlayersInterval !== 0) {
return;
}
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 preMove
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
roles.squadsiege.preMove = function(creep, directions) {
// creep.log('preMove');
if (!directions) {
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 destroyStructureWall
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.destroyStructureWall = function(structure) {
if (!structure.hits) {
return false;
}
if (!this.memory.walls) {
- 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 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
roles.atkeeper.action = function(creep) {
// TODO Untested
creep.spawnReplacement();
creep.setNextSpawn();
const center = new RoomPosition(25, 25, creep.memory.routing.targetRoom);
Function defendTower
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
roles.nextroomer.defendTower = function(creep) {
const room = Game.rooms[creep.room.name];
const constructionSites = creep.pos.findInRange(FIND_CONSTRUCTION_SITES, 1);
if (constructionSites.length > 0) {
creep.build(constructionSites[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 harvestCommodities
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.harvestCommodities = function() {
if (config.commodities.disabled) {
return false;
}
if (!Memory.commodities) {
Function buildBase
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.buildBase = function() {
// version: this.memory.position.version is maybe not the best idea
if (this.data.positions.version !== config.layout.version) {
this.debugLog('baseBuilding', 'New layout version, rebuilding');
this.memory = {};
- 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 closeExitsByPath
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.closeExitsByPath = function() {
if (this.memory.walls && this.memory.walls.finished) {
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 costMatrixPathCrossings
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.costMatrixPathCrossings = function(exits) {
return () => {
for (const startDir in exits) {
if (!startDir) {
continue;
- 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 spawnKeepersEveryTicks
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.spawnKeepersEveryTicks = function(ticks) {
let returnValue = false;
const baseRoom = Game.rooms[this.data.base];
if (baseRoom && baseRoom.controller) {
if (baseRoom.controller.level >= config.keepers.minControllerLevel) {
- 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 spawnKeepers
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.spawnKeepers = function() {
const room = this;
const keeperPositions = this.data.keepers;
const baseRoom = Game.rooms[this.data.base];
const amount = 1;
Function sendPowerOwnRooms
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.sendPowerOwnRooms = function() {
if (this.terminal && this.terminal.cooldown === 0 && this.terminal.store[RESOURCE_POWER] > 100) {
let sendOnce = false;
const powerTransfer = _.map(_.shuffle(Memory.myRooms), (myRoom) => {
if (!Game.rooms[myRoom]) {
- 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 getEnergyFromStructure
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.getEnergyFromStructure = function() {
if (this.carry.energy === this.carryCapacity) {
return false;
}
const area = this.room.lookForAtArea(
- 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 moveRandomWithin
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.moveRandomWithin = function(goal, dist = 3, goal2 = false) {
const startDirection = _.random(1, 8);
let direction = 0;
for (let i = 0; i < 8; i++) {
direction = RoomPosition.changeDirection(startDirection, i);
- 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 checkBlocked
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.checkBlocked = function() {
const exits = Game.map.describeExits(this.name);
const callerRoom = this;
const roomCallback = (roomName) => {
const room = Game.rooms[roomName] || callerRoom;
- 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 getMyRoomWithinRange
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function getMyRoomWithinRange(roomName, range=0, minRCL=0, minStorageEnergyPercentage=0) {
// TODO Instead of just finding one room, it should be the closest (or highest RCL)
for (const myRoomName of Memory.myRooms) {
const room = Game.rooms[myRoomName];
if (!room) {
- 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 checkBlockers
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.checkBlockers = function() {
if (this.controller.level === 1) {
return false;
}
// this.log('checkBlockers: ' + this.memory.controllerLevel.checkBlockersInterval + ' ' + this.controller.level + ' ' + this.memory.walls);
- 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 spawnCarry
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.spawnCarry = function() {
if (this.memory.wait > 0) {
this.memory.wait -= 1;
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 findRoomAndSpawn
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
async function findRoomAndSpawn(shardsReduced) {
for (const shard of shardsReduced) {
const rooms = await getWorldStartRooms(shard.name);
for (const roomCenter of rooms.room) {
const matcher = /(\D+)(\d+)(\D+)(\d+)/;
- 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 checkExitsAreReachable
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.checkExitsAreReachable = function() {
// Make sure every exit is reachable
const inLayer = function(room, pos) {
for (let i = 0; i < room.memory.walls.layer_i; i++) {