TooAngel/screeps

View on GitHub

Showing 594 of 594 total issues

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      updateCreeps: function(event, status) {
        const creeps = _.filter(event.data.objects, filter.creeps);
        if (_.size(creeps) > 0) {
          status[event.id].creeps += _.size(creeps);
        }
    Severity: Major
    Found in utils/testHelpers.js and 1 other location - About 2 hrs to fix
    utils/testHelpers.js on lines 318..323

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 86.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      updateStructures: function(event, status) {
        const structures = _.filter(event.data.objects, filter.structures);
        if (_.size(structures) > 0) {
          status[event.id].structures += _.size(structures);
        }
    Severity: Major
    Found in utils/testHelpers.js and 1 other location - About 2 hrs to fix
    utils/testHelpers.js on lines 312..317

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 86.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

      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

        Severity
        Category
        Status
        Source
        Language