TooAngel/screeps

View on GitHub

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;
  }

Severity: Minor
Found in src/prototype_creep_startup_tasks.js - About 25 mins to fix

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)) {
Severity: Minor
Found in src/prototype_room_wallsetter.js - About 25 mins to fix

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);
Severity: Minor
Found in src/prototype_room_external.js - About 25 mins to fix

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
Severity: Minor
Found in src/role_structurer.js - About 25 mins to fix

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()) {
Severity: Minor
Found in src/role_upgrader.js - About 25 mins to fix

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();
Severity: Minor
Found in src/pixel.js - About 25 mins to fix

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) {
Severity: Minor
Found in src/prototype_room_external.js - About 25 mins to fix

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);
Severity: Minor
Found in src/role_defendmelee.js - About 25 mins to fix

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();
Severity: Minor
Found in src/prototype_room_creepbuilder.js - About 25 mins to fix

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) {
Severity: Minor
Found in src/brain_squadmanager.js - About 25 mins to fix

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 = {};
  }

Severity: Minor
Found in src/brain_squadmanager.js - About 25 mins to fix

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) {
Severity: Minor
Found in src/prototype_room_routing.js - About 25 mins to fix

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;
Severity: Minor
Found in src/prototype_room_basebuilder.js - About 25 mins to fix

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;
Severity: Minor
Found in src/prototype_room_basebuilder.js - About 25 mins to fix

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)) {
Severity: Minor
Found in src/prototype_creep_resources.js - About 25 mins to fix

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;
  }
Severity: Minor
Found in src/prototype_creep_resources.js - About 25 mins to fix

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) {
Severity: Minor
Found in src/prototype_roomPosition.js - About 25 mins to fix

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);
Severity: Minor
Found in src/prototype_creep_resources.js - About 25 mins to fix

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) {
Severity: Minor
Found in src/prototype_creep_resources.js - About 25 mins to fix

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);
Severity: Minor
Found in src/prototype_room_routing.js - About 25 mins to fix

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

Severity
Category
Status
Source
Language