Showing 886 of 1,349 total issues
File main.ts
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global RawMemory */
// Make sure game object prototypes are enhanced.
import {ErrorMapper} from 'utils/ErrorMapper';
Function performMilitaryAttack
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
performMilitaryAttack(creep: BrawlerCreep) {
if (creep.memory.order) {
// Attack ordered target first.
const target = Game.getObjectById<Creep | AnyOwnedStructure>(creep.memory.order.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 getBaseUpgraderAmount
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
getBaseUpgraderAmount(room: Room): number {
// Early on, builders will take care of upgrading once necessary
// structures have been built.
if (!room.storage && !room.terminal) return 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 getRegions
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
getRegions(exits: ExitInfo[]): RegionInfo[] {
this.exitLookup = {};
for (const exit of exits) {
this.exitLookup[exit.id] = exit;
}
- 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 isEnemyCloseToImportantStructures
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
isEnemyCloseToImportantStructures(): boolean {
for (const structure of this.getImportantStructures()) {
for (const userName in this.room.enemyCreeps) {
if (hivemind.relations.isAlly(userName)) 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 addOptionsForTarget
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
addOptionsForTarget(info: PowerTargetRoom, roomName: string, sourceRoom: Room, options: PowerHarvesterSpawnOption[]) {
// We're assigned to spawn creeps for this power gathering operation!
const activePowerHarvesters = _.filter(Game.creepsByRole['harvester.power'] || [], (creep: Creep) => {
if (creep.memory.isHealer) return false;
if (creep.memory.sourceRoom !== sourceRoom.name) 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 getRegions
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
getRegions(exits: ExitInfo[]): RegionInfo[] {
this.exitLookup = {};
for (const exit of exits) {
this.exitLookup[exit.id] = exit;
}
CombatManager
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
export default class CombatManager {
tileCache: Record<number, number>;
tileCacheTime: number;
hasRangedAttacked: boolean;
Function calculateAdjacentRoomSafety
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
calculateAdjacentRoomSafety(options?: {safe?: string[]; unsafe?: string[]}): {directions: Record<string, boolean>; safeRooms: string[]} {
return cache.inHeap('adjacentSafety:' + this.roomName, 100, () => {
if (!this.memory.exits) {
return {
directions: {
Function getOntoCachedPath
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
Creep.prototype.getOntoCachedPath = function (this: Creep | PowerCreep) {
const creep = this;
const target = this.pos.findClosestByRange(this.getCachedPath(), {
filter: pos => {
// Try to move to a position on the path that is in the current room.
Function addRepairOptions
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
addRepairOptions(creep: BuilderCreep, options: OrderOption[]) {
const targets = _.filter(
this.getAvailableRepairTargets(creep),
structure => structure.hits < structure.hitsMax
&& !structure.needsDismantling()
- 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 ensureRemoteHarvestContainerIsBuilt
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
ensureRemoteHarvestContainerIsBuilt(creep: MineBuilderCreep) {
if (!(creep.operation instanceof RemoteMiningOperation)) return false;
if ((creep.store.energy || 0) === 0) return false;
const workParts = creep.getActiveBodyparts(WORK) || 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 depositResources
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
depositResources(creep: HarvesterCreep, source: Source | Mineral) {
const harvestPower = (source instanceof Source) ? HARVEST_POWER : HARVEST_MINERAL_POWER;
if (creep.store.getFreeCapacity() >= creep.getActiveBodyparts(WORK) * harvestPower) return;
const targetContainer = source.getNearbyContainer();
- 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 getAlternateCreepPosition
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
getAlternateCreepPosition(creep: Creep | PowerCreep): RoomPosition | null {
if (!creep._requestedMoveArea && !creep._alternatePositions) return null;
let alternatePosition: RoomPosition;
const costMatrix = getCostMatrix(creep.room.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"
Further reading
Function placeLabs
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
placeLabs() {
this.placementManager.startBuildingPlacement();
while (this.roomPlan.canPlaceMore('lab')) {
const nextPos = this.placementManager.getNextAvailableBuildSpot();
if (!nextPos) return 'failed';
- 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 getRampartGroups
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
getRampartGroups(): RoomPosition[][] {
const allRamparts = _.map(this.roomPlan.getPositions('rampart'), pos => ({
pos,
isUsed: 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 constructor
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
constructor(pos: RoomPosition, hasHarvester: boolean) {
this.pos = pos;
this.name = encodePosition(pos);
this._hasHarvester = hasHarvester;
this.extensions = [];
- 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
PlacementManager
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
export default class PlacementManager {
public get ROAD_POSITION() {
return 1;
}
Function performGetRemoteBuilderEnergy
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
performGetRemoteBuilderEnergy() {
// @todo Switch to using priority list to determine where to get energy.
const creep = this.creep;
// Move to source room if necessary.
- 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 getAvailableRepairTargets
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
getAvailableRepairTargets(creep: BuilderCreep): Array<Structure<BuildableStructureConstant>> {
const repairableStructureIds = cache.inHeap('repairStructures:' + creep.room.name, 50, () => {
const repairableStructures = _.filter(creep.room.structures, (structure: Structure<BuildableStructureConstant>) => {
if (structure.hits >= this.getStructureMaxHits(structure)) return false;
if (structure.needsDismantling()) 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"