TooAngel/screeps

View on GitHub

Showing 492 of 594 total issues

Avoid too many return statements within this function.
Open

    return;
Severity: Major
Found in src/brain_nextroom.js - About 30 mins to fix

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

    Room.prototype.handleLinks = function() {
      const linkStorage = this.getLinkStorage();
      // Only send energy if linkStorage is set and free capacity is higher or equals than 400 Energy
      if (!linkStorage || linkStorage.store.getFreeCapacity(RESOURCE_ENERGY) < 400) {
        return;
    Severity: Minor
    Found in src/prototype_room_my.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 checkIfBuildRoadIsPossible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.checkIfBuildRoadIsPossible = function() {
      if (!this.unit().buildRoad) {
        return false;
      }
    
    
    Severity: Minor
    Found in src/prototype_creep.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 searchPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.searchPath = function(target, range=1, withinRoom=false) {
      let costMatrixCallback;
      if (this.room.memory.misplacedSpawn) {
        costMatrixCallback = this.room.getBasicCostMatrixCallback(withinRoom);
      } else {
    Severity: Minor
    Found in src/prototype_creep_move.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 handleReviveRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.handleReviveRoom = function(hostiles) {
      if (!this.executeEveryTicks(config.carryHelpers.ticksUntilHelpCheck)) {
        return false;
      }
    
    
    Severity: Minor
    Found in src/prototype_room_my.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 repairRoadOnSpot has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.repairRoadOnSpot = function() {
      const structures = this.pos.lookFor(LOOK_STRUCTURES);
      if (structures.length > 0) {
        for (const structure of structures) {
          if ((structure.structureType === STRUCTURE_ROAD) && (structure.hits < structure.hitsMax)) {
    Severity: Minor
    Found in src/prototype_creep.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 settle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    roles.nextroomer.settle = function(creep) {
      creep.creepLog('settle');
      const room = Game.rooms[creep.room.name];
    
      const handledHostiles = handleHostile(creep, room);
    Severity: Minor
    Found in src/role_nextroomer.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 buyLowCostResources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.buyLowCostResources = function() {
      if ((Game.market.credits < config.market.minCredits) || (this.terminal.cooldown > 0)) {
        return false;
      }
      const room = this.name;
    Severity: Minor
    Found in src/prototype_room_market.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      render() {
        if (config.visualizer.showCostMatrices) {
          this.showCostMatrices();
        }
        if (config.visualizer.showRoomPaths) {
    Severity: Minor
    Found in src/visualizer.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 spawnDefender has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.spawnDefender = function() {
      if (this.memory.attackTimer > 15) {
        if (this.executeEveryTicks(250)) {
          const role = this.memory.attackTimer > 300 ? 'defendmelee' : 'defendranged';
          this.checkRoleToSpawn(role, 1, undefined, this.name, 1, this.name);
    Severity: Minor
    Found in src/prototype_room_my.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 findStructuresWithUsableEnergy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.findStructuresWithUsableEnergy = function() {
      return this.find(FIND_MY_STRUCTURES, {filter: (object) => {
        if (!object.store) {
          return false;
        }
    Severity: Minor
    Found in src/prototype_room_find.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.mineral.action = function(creep) {
      creep.say('mineral');
      // creep.log(`mineral: ${JSON.stringify(creep.data.state)}`);
    
      if (creep.room.memory.boosts && Object.keys(creep.room.memory.boosts).length > 0) {
    Severity: Minor
    Found in src/role_mineral.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 fleeFromHostile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.fleeFromHostile = function(hostile) {
      let direction = RoomPosition.oppositeDirection(this.pos.getDirectionTo(hostile));
      if (!direction || direction === null || this.pos.isBorder(-1)) {
        this.moveTo(25, 25);
        return true;
    Severity: Minor
    Found in src/prototype_creep_fight.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 handleDefender has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Creep.prototype.handleDefender = function() {
      const hostile = this.findClosestEnemy();
    
      if (this.fightRampart(hostile)) {
        return true;
    Severity: Minor
    Found in src/prototype_creep_fight.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 getRoomNameToObserve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.getRoomNameToObserve = function() {
      // TODO scan full range, first implementation
      const nameSplit = this.splitRoomName();
      const observerRange = Math.max(Math.min(config.room.observerRange, OBSERVER_RANGE), 1);
      const fullLength = 2 * observerRange + 1;
    Severity: Minor
    Found in src/prototype_room_my.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 handleDefence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Room.prototype.handleDefence = function(hostiles) {
      if (hostiles.length === 0) {
        return;
      }
    
    
    Severity: Minor
    Found in src/prototype_room_my.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 cleanSquads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function cleanSquads() {
      if (Game.time % 1500 === 0) {
        for (const squadId of Object.keys(Memory.squads)) {
          const squad = Memory.squads[squadId];
          if (Game.time - squad.born > 3000) {
    Severity: Minor
    Found in src/brain_memory.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 handleHostile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function handleHostile(creep, room) {
      const hostileCreeps = room.find(FIND_HOSTILE_CREEPS, {
        filter: (creep) => (!room.controller.safeMode || creep.ticksToLive > room.controller.safeMode) && !isFriend(creep.owner.username),
      });
      if (!hostileCreeps.length) {
    Severity: Minor
    Found in src/role_nextroomer.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 handleExits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function handleExits(room, costMatrix, allowExits) {
      if (allowExits) {
        for (let i = 0; i < 50; i++) {
          openExits(costMatrix, i, 0, room);
          openExits(costMatrix, i, 49, room);
    Severity: Minor
    Found in src/prototype_room_costmatrix.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 callbackCloseExitsByPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const callbackCloseExitsByPath = function(room) {
      return (roomName, costMatrix) => {
        if (!costMatrix) {
          costMatrix = new PathFinder.CostMatrix();
        }
    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

    Severity
    Category
    Status
    Source
    Language