TooAngel/screeps

View on GitHub

Showing 492 of 594 total issues

Function sellByOthersOrders has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

Room.prototype.sellByOthersOrders = function(sellAmount, resource, force) {
  const sortByEnergyCostAndPrice = (order) => Game.market.calcTransactionCost(sellAmount, this.name, order.roomName) +
  -order.price * sellAmount / config.market.energyCreditEquivalent;
  if (Memory.orders[ORDER_BUY][resource]) {
    const orders = _.sortBy(Memory.orders[ORDER_BUY][resource].orders, sortByEnergyCostAndPrice);
Severity: Minor
Found in src/prototype_room_market.js - About 3 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 preMoveExtractorSourcer has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

Creep.prototype.preMoveExtractorSourcer = function(directions) {
  this.pickupEnergy();

  // Sourcer keeper handling
  if (!this.room.controller) {
Severity: Minor
Found in src/prototype_creep_move.js - About 3 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

File config.js has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

global.brain = {
  stats: {},
  main: {},
Severity: Minor
Found in src/config.js - About 3 hrs to fix

    File role_carry.js has 296 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    /*
     * carry gets energy and brings it to the storage
     *
    Severity: Minor
    Found in src/role_carry.js - About 3 hrs to fix

      Function buildRampartsAroundSpawns has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.buildRampartsAroundSpawns = function() {
        // Build ramparts around the spawn if wallThickness > 1
        // TODO this is not used for a long time and the spawn positions should
        // be taken from `memory.positions.spawn`
        if (config.layout.wallThickness > 1) {
      Severity: Minor
      Found in src/prototype_room_basebuilder.js - About 3 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 21 (exceeds 5 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 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 handleSquadManager has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.handleSquadManager = function() {
        if (Object.keys(Memory.squads).length > 0) {
          debugLog('brain', 'brain.handleSquadManager squads: ${Object.keys(Memory.squads).length}');
        }
        for (const squadIndex of Object.keys(Memory.squads)) {
      Severity: Minor
      Found in src/brain_squadmanager.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 inPositions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      RoomPosition.prototype.inPositions = function() {
        const room = this.getRoom();
        if (!room.data.positions) {
          return false;
        }
      Severity: Minor
      Found in src/prototype_roomPosition.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 getCostMatrix has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      Room.prototype.getCostMatrix = function() {
        const costMatrix = new PathFinder.CostMatrix();
        // Keep distance to walls
        for (let x = 0; x < 50; x++) {
          for (let y = 0; y < 50; y++) {
      Severity: Minor
      Found in src/prototype_room_costmatrix.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 buildRoads has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      Creep.buildRoads = function(creep) {
        const room = Game.rooms[creep.room.name];
      
        // TODO extract to RoomPosition
        /**
      Severity: Minor
      Found in src/prototype_creep_startup_tasks.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 checkExitsAreReachable has a Cognitive Complexity of 20 (exceeds 5 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 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

      File find.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      Room.prototype.findHostileStructureWithEnergy = function() {
        return this.find(FIND_HOSTILE_STRUCTURES, {
          filter: (object) => object.store && object.store.energy,
      Severity: Minor
      Found in src/find.js - About 2 hrs to fix

        Function prepareBoost has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        function prepareBoost(creep) {
          for (const creepName of Object.keys(creep.room.memory.boosts)) {
            const config = creep.room.memory.boosts[creepName];
            if (config.time + 1500 < Game.time) {
              creep.room.debugLog('boosts', `Deleting old config ${JSON.stringify(config)}`);
        Severity: Minor
        Found in src/role_mineral.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 prepareBoosting has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        function prepareBoosting(room, creep, config) {
          if (!room.terminal || !room.terminal.my) {
            return false;
          }
        
        
        Severity: Minor
        Found in src/prototype_room_creepbuilder.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 cleanSetTargetId has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        Creep.prototype.cleanSetTargetId = function() {
          if (!this.room.isMy()) {
            //    this.log('no targetId');
            if (this.cleanController()) {
              //      this.log('clean controller');
        Severity: Minor
        Found in src/prototype_creep_clean.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 setupStructure has a Cognitive Complexity of 19 (exceeds 5 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 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 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        roles.atkeepermelee.action = function(creep) {
          // TODO Untested
          creep.spawnReplacement();
          creep.setNextSpawn();
          creep.memory.canHeal = creep.getActiveBodyparts(HEAL) > 0;
        Severity: Major
        Found in src/role_atkeepermelee.js - About 2 hrs to fix

          Function showStructures has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            showStructures() {
              for (const room of _.values(Game.rooms)) {
                if (!room.isMy()) {
                  continue;
                }
          Severity: Minor
          Found in src/visualizer.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 showCostMatrix has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            showCostMatrix(roomName, costMatrixCallback) {
              const rv = new RoomVisual(roomName);
              const cm = costMatrixCallback(roomName);
              if (cm) {
                for (let x = 0; x < 50; ++x) {
          Severity: Minor
          Found in src/visualizer.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 showBlockers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            showBlockers() {
              for (const room of _.values(Game.rooms)) {
                if (!room.isMy()) {
                  continue;
                }
          Severity: Minor
          Found in src/visualizer.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

          Severity
          Category
          Status
          Source
          Language