TooAngel/screeps

View on GitHub

Showing 594 of 594 total issues

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

Function pickupEnergyFromGround has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Creep.prototype.pickupEnergyFromGround = function() {
  const resources = this.pos.findInRange(FIND_DROPPED_RESOURCES, 1, {
    filter: {resourceType: RESOURCE_ENERGY},
  });
  if (resources.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 getRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Creep.prototype.getRoute = function() {
  if (this.memory.routing.route) {
    return this.memory.routing.route;
  }

Severity: Minor
Found in src/prototype_creep_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 checkPositions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Room.prototype.checkPositions = function() {
  for (const type of [STRUCTURE_SPAWN, STRUCTURE_EXTENSION, STRUCTURE_TOWER, STRUCTURE_LINK, STRUCTURE_OBSERVER, STRUCTURE_NUKER, STRUCTURE_FACTORY]) {
    if ((this.data.positions.structure[type] || []).length < CONTROLLER_STRUCTURES[type][8]) {
      let output = 'Structures not found:\n';
      for (const type of Object.keys(this.data.positions.structure)) {
Severity: Minor
Found in src/prototype_room_init.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.powerdefender.action = function(creep) {
  if (creep.hits < 200) {
    return false;
  }
  const hostileCreeps = creep.room.findEnemies();
Severity: Minor
Found in src/role_powerdefender.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 getPathLength has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getPathLength(pathObject) {
  let lastPos;
  let value = 0;
  for (const pos of pathObject.path) {
    let valueAdd = 0;
Severity: Minor
Found in src/prototype_room_init.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 findKeepersAt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

Room.prototype.findKeepersAt = function(roles, posId) {
  const s = Game.getObjectById(posId);
  const type = s.energy > 0 ? 'energy' : ((s.mineralAmount > 0) ? 'mineral' : 'offline');
  const amount = (s.energy > 1000) ? s.energy : ((s.mineralAmount > 2000) ? s.mineralAmount : false);
  const room = this;
Severity: Minor
Found in src/prototype_room_keeper.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 updateSkippedRoomsLog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function updateSkippedRoomsLog() {
  Memory.skippedRoomsLog = Memory.skippedRoomsLog || {};
  if (_.size(Memory.skippedRooms) > 0) {
    console.log(`${Game.time} cpu.getUsed: ${_.round(Game.cpu.getUsed())} tickLimit: ${Game.cpu.tickLimit} Bucket: ${Game.cpu.bucket} skippedRooms ${Memory.skippedRooms}`);
    Memory.skippedRoomsLog[Game.time] = Memory.skippedRooms;
Severity: Minor
Found in src/brain_main.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 isClaimableRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function isClaimableRoom(roomName) {
  const data = global.data.rooms[roomName];
  if (Memory.myRooms.indexOf(roomName) >= 0) {
    return false;
  }
Severity: Minor
Found in src/brain_nextroom.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 checkForSuccess has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async checkForSuccess(line, defer) {
    if (botsSpawned && line.startsWith(`'OK'`)) {
      let appendix = '';
      if (this.maxRuntime > 0) {
        appendix = ` with runtime ${this.maxRuntime / 60} minutes`;
Severity: Minor
Found in utils/test.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.towerdrainer.action = function(creep) {
  const attackRoom = creep.memory.attackRoom;
  const restPos = roles.towerdrainer.getRestPosition(creep);
  if (!restPos) {
    creep.log('no position');
Severity: Minor
Found in src/role_towerdrainer.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 getFailedRooms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getFailedRooms(milestone) {
  const failedRooms = [];
  for (const room of Object.keys(status)) {
    for (const key of Object.keys(milestone.check)) {
      if (status[room][key] < milestone.check[key]) {
Severity: Minor
Found in utils/test.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 handleNextroomer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

brain.handleNextroomer = function() {
  if (!Memory.myRooms) {
    return;
  }
  if (Memory.myRooms.length >= Game.gcl.level) {
Severity: Minor
Found in src/brain_nextroom.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