TooAngel/screeps

View on GitHub

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 || {};
Severity: Minor
Found in src/diplomacy.js - About 2 hrs 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 18 (exceeds 5 allowed). Consider refactoring.
Open

roles.squadsiege.preMove = function(creep, directions) {
  // creep.log('preMove');
  if (!directions) {
    return false;
  }
Severity: Minor
Found in src/role_squadsiege.js - About 2 hrs 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 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) {
Severity: Minor
Found in src/prototype_room_basebuilder.js - About 2 hrs 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 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);
Severity: Major
Found in src/role_atkeeper.js - About 2 hrs to fix

    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]);
    Severity: Minor
    Found in src/role_nextroomer.js - About 2 hrs 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 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) {
    Severity: Major
    Found in src/prototype_room_external.js - About 2 hrs to fix

      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 = {};
      Severity: Minor
      Found in src/prototype_room_controller.js - About 2 hrs 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 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;
        }
      
      
      Severity: Minor
      Found in src/prototype_room_wallsetter.js - About 2 hrs 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 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;
      Severity: Minor
      Found in src/prototype_room_init.js - About 2 hrs 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 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) {
      Severity: Minor
      Found in src/prototype_room_keeper.js - About 2 hrs 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 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;
      Severity: Minor
      Found in src/prototype_room_keeper.js - About 2 hrs to fix

        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]) {
        Severity: Minor
        Found in src/prototype_room_market.js - About 1 hr 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 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(
        Severity: Minor
        Found in src/prototype_creep.js - About 1 hr 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 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);
        Severity: Minor
        Found in src/prototype_creep_move.js - About 1 hr 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 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;
        Severity: Minor
        Found in src/prototype_room_external.js - About 1 hr 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 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) {
        Severity: Minor
        Found in src/helper_findMyRooms.js - About 1 hr 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 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);
        Severity: Minor
        Found in src/prototype_room_basebuilder.js - About 1 hr 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 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;
          }
        Severity: Minor
        Found in src/prototype_creep_harvest.js - About 1 hr 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 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+)/;
        Severity: Minor
        Found in utils/respawner.js - About 1 hr 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 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++) {
        Severity: Minor
        Found in src/prototype_room_wallsetter.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language