TooAngel/screeps

View on GitHub
src/prototype_room_keeper.js

Summary

Maintainability
B
5 hrs
Test Coverage

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

    Avoid deeply nested control flow statements.
    Open

              if (returnValue && returnValue[0] && returnValue[0][0] && returnValue[0][0].success) {
                this.log('spawnKeepers', JSON.stringify(returnValue[0]));
              }
    Severity: Major
    Found in src/prototype_room_keeper.js - About 45 mins to fix

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

      Room.prototype.findKeepersAt = function(roles, posId) {
        const s = Game.getObjectById(posId);
        const type = s.energy > 0 ? 'energy' : ((s.mineralAmount > 0) ? 'mineral' : 'offline');
        const amount = (s.energy > 1000) ? s.energy : ((s.mineralAmount > 2000) ? s.mineralAmount : false);
        const room = this;
      Severity: Minor
      Found in src/prototype_room_keeper.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

      There are no issues that match your filters.

      Category
      Status