TooAngel/screeps

View on GitHub

Showing 492 of 594 total issues

Function repairStructure has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Creep.prototype.repairStructure = function() {
  if (this.repairKnownTarget()) {
    return true;
  }

Severity: Minor
Found in src/prototype_creep_startup_tasks.js - About 1 hr to fix

    Function getAttackAction has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getAttackAction(player) {
      const actions = [
        {
          name: 'simpleAttack',
          value: -1 * 1500,
    Severity: Minor
    Found in src/diplomacy.js - About 1 hr to fix

      Function findAttackCreeps has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.findAttackCreeps = function(object) {
        if (object.owner.username === 'Source Keeper') {
          return false;
        }
      
      
      Severity: Minor
      Found in src/prototype_room_defense.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 buyByOthersOrders has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.buyByOthersOrders = function(resource) {
        const avgBuyPrice = brain.getMarketOrderAverage(ORDER_BUY, resource);
        const myBuyPrice = Math.min((avgBuyPrice || 1) * config.market.buyOrderPriceMultiplicand, config.market.maxBuyPrice);
        const buyAmount = config.market.maxAmountToBuy - (this.terminal.store[resource] || 0);
      
      
      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 cleanCreeps has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function cleanCreeps() {
        // Cleanup memory
        if (!Memory.creeps) {
          return;
        }
      Severity: Minor
      Found in src/brain_memory.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 dismantleStructure has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      roles.carry.dismantleStructure = function(creep, directions) {
        const posForward = creep.pos.getAdjacentPosition(directions.direction);
        const structures = posForward.lookFor(LOOK_STRUCTURES);
        for (const structure of structures) {
          if (structure.structureType === STRUCTURE_ROAD) {
      Severity: Minor
      Found in src/role_carry.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 spawnCreepsForReservation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function spawnCreepsForReservation(reservationCandidate) {
        for (const roomName of findMyRoomsSortByDistance(reservationCandidate.name)) {
          const room = Game.rooms[roomName];
          if (!room) {
            continue;
      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 repairStructureWithIncomingNuke has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      Creep.prototype.repairStructureWithIncomingNuke = function() {
        const nukes = this.room.findNukes();
        if (nukes.length === 0) {
          return false;
        }
      Severity: Minor
      Found in src/prototype_creep_startup_tasks.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 setup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.setup = function() {
        this.debugLog('baseBuilding', `Setup`);
        if (this.memory.setup) {
          if (this.memory.setup.completed) {
            throw new Error('Setup called, while it was already completed');
      Severity: Minor
      Found in src/prototype_room_init.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 haveEnoughSystemResources has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function haveEnoughSystemResources() {
        if (config.nextRoom.resourceStats) {
          debugLog('nextroomer', `stats: ${JSON.stringify(global.data.stats)}`);
          const myRoomsLength = Memory.myRooms.length;
          const cpuPerRoom = global.data.stats.cpuUsed / myRoomsLength;
      Severity: Minor
      Found in src/brain_nextroom.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 getMatrixCallback has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.getMatrixCallback = function(end) {
        // TODO cache?!
        const callback = (roomName) => {
          const room = Game.rooms[roomName];
          const costMatrix = new PathFinder.CostMatrix();
      Severity: Minor
      Found in src/prototype_room_routing.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 handle has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Creep.prototype.handle = function() {
        this.memory.room = this.pos.roomName;
        if (!this.checkForHandle()) {
          return;
        }
      Severity: Minor
      Found in src/prototype_creep.js - About 1 hr to fix

        Function preMove has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        roles.carry.preMove = function(creep, directions) {
          if (!validateDirections(creep, directions)) {
            return false;
          }
        
        
        Severity: Minor
        Found in src/role_carry.js - About 1 hr to fix

          Function setLabs has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Room.prototype.setLabs = function(allPaths) {
            let lab1Pos;
            let lab2Pos;
            let pathI;
            let path;
          Severity: Minor
          Found in src/prototype_room_init.js - About 1 hr to fix

            Function killPrevious has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Creep.prototype.killPrevious = function(path) {
              if (this.memory.routing.routePos !== this.memory.routing.route.length - 1) {
                return false;
              }
            
            
            Severity: Minor
            Found in src/prototype_creep.js - About 1 hr to fix

              Function setupStructure has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Room.prototype.setupStructure = function(structure) {
                const constructionSites = this.find(FIND_CONSTRUCTION_SITES, {filter: (object) => object.structureType === structure});
                if (setupStructureFinishPriorityStructures(structure, constructionSites)) {
                  return true;
                }
              Severity: Minor
              Found in src/prototype_room_basebuilder.js - About 1 hr to fix

                Function buildPath has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Room.prototype.buildPath = function(route, routePos, from, to) {
                  if (!to) {
                    throw new Error();
                  }
                  let start;
                Severity: Minor
                Found in src/prototype_room_routing.js - About 1 hr to fix

                  Function defendTower has 40 lines of code (exceeds 25 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 1 hr to fix

                    Function preMove has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    roles.squadheal.preMove = function(creep, directions) {
                      creep.creepLog('preMove');
                      if (creep.hits < creep.hitsMax) {
                        creep.creepLog('preMove heal');
                        creep.selfHeal();
                    Severity: Minor
                    Found in src/role_squadheal.js - About 1 hr to fix

                      Function spawnCarry has 40 lines of code (exceeds 25 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
                        Severity
                        Category
                        Status
                        Source
                        Language