Showing 492 of 594 total issues
Function repairStructure
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.repairStructure = function() {
if (this.repairKnownTarget()) {
return true;
}
Function getAttackAction
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getAttackAction(player) {
const actions = [
{
name: 'simpleAttack',
value: -1 * 1500,
Function findAttackCreeps
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.findAttackCreeps = function(object) {
if (object.owner.username === 'Source Keeper') {
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 buyByOthersOrders
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.buyByOthersOrders = function(resource) {
const avgBuyPrice = brain.getMarketOrderAverage(ORDER_BUY, resource);
const myBuyPrice = Math.min((avgBuyPrice || 1) * config.market.buyOrderPriceMultiplicand, config.market.maxBuyPrice);
const buyAmount = config.market.maxAmountToBuy - (this.terminal.store[resource] || 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 cleanCreeps
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function cleanCreeps() {
// Cleanup memory
if (!Memory.creeps) {
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 dismantleStructure
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
roles.carry.dismantleStructure = function(creep, directions) {
const posForward = creep.pos.getAdjacentPosition(directions.direction);
const structures = posForward.lookFor(LOOK_STRUCTURES);
for (const structure of structures) {
if (structure.structureType === STRUCTURE_ROAD) {
- 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 spawnCreepsForReservation
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function spawnCreepsForReservation(reservationCandidate) {
for (const roomName of findMyRoomsSortByDistance(reservationCandidate.name)) {
const room = Game.rooms[roomName];
if (!room) {
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 repairStructureWithIncomingNuke
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.repairStructureWithIncomingNuke = function() {
const nukes = this.room.findNukes();
if (nukes.length === 0) {
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 setup
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.setup = function() {
this.debugLog('baseBuilding', `Setup`);
if (this.memory.setup) {
if (this.memory.setup.completed) {
throw new Error('Setup called, while it was already completed');
- 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 haveEnoughSystemResources
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function haveEnoughSystemResources() {
if (config.nextRoom.resourceStats) {
debugLog('nextroomer', `stats: ${JSON.stringify(global.data.stats)}`);
const myRoomsLength = Memory.myRooms.length;
const cpuPerRoom = global.data.stats.cpuUsed / myRoomsLength;
- 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 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 handle
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.handle = function() {
this.memory.room = this.pos.roomName;
if (!this.checkForHandle()) {
return;
}
Function preMove
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
roles.carry.preMove = function(creep, directions) {
if (!validateDirections(creep, directions)) {
return false;
}
Function setLabs
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.setLabs = function(allPaths) {
let lab1Pos;
let lab2Pos;
let pathI;
let path;
Function killPrevious
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.killPrevious = function(path) {
if (this.memory.routing.routePos !== this.memory.routing.route.length - 1) {
return false;
}
Function setupStructure
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Room.prototype.setupStructure = function(structure) {
const constructionSites = this.find(FIND_CONSTRUCTION_SITES, {filter: (object) => object.structureType === structure});
if (setupStructureFinishPriorityStructures(structure, constructionSites)) {
return true;
}
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 defendTower
has 40 lines of code (exceeds 25 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]);
Function preMove
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
roles.squadheal.preMove = function(creep, directions) {
creep.creepLog('preMove');
if (creep.hits < creep.hitsMax) {
creep.creepLog('preMove heal');
creep.selfHeal();
Function spawnCarry
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.spawnCarry = function() {
if (this.memory.wait > 0) {
this.memory.wait -= 1;
return false;
}