TooAngel/screeps

View on GitHub
src/prototype_room_creepbuilder.js

Summary

Maintainability
D
2 days
Test Coverage

File prototype_room_creepbuilder.js has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const {
  CreepPartData,
  sortCreepParts,
Severity: Minor
Found in src/prototype_room_creepbuilder.js - About 6 hrs to fix

    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 getPartConfig has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Room.prototype.getPartConfig = function(creep) {
      // TODO this needs to be rethought and rebuild (more simple)
      let energyAvailable = this.energyAvailable;
      const settings = this.getSettings(creep);
      const {
    Severity: Minor
    Found in src/prototype_room_creepbuilder.js - About 1 hr to fix

      Function stringToParts has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function stringToParts(stringParts) {
        if (!stringParts || typeof (stringParts) !== 'string') {
          return undefined;
        }
        const arrayParts = [];
      Severity: Minor
      Found in src/prototype_room_creepbuilder.js - About 1 hr to fix

        Function getPartConfig has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        Room.prototype.getPartConfig = function(creep) {
          // TODO this needs to be rethought and rebuild (more simple)
          let energyAvailable = this.energyAvailable;
          const settings = this.getSettings(creep);
          const {
        Severity: Minor
        Found in src/prototype_room_creepbuilder.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 getCreepConfig has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Room.prototype.getCreepConfig = function(creep) {
          const role = creep.role;
          const unit = roles[role];
          if (!unit) {
            this.log('Can not find role: ' + role + ' creep_' + role);
        Severity: Minor
        Found in src/prototype_room_creepbuilder.js - About 1 hr to fix

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

            Function checkRoleToSpawn has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            Room.prototype.checkRoleToSpawn = function(role, amount, targetId, targetRoom, level, base, additionalMemory = {}) {
              const creepMemory = this.creepMem(role, targetId, targetRoom, level, base);
              Object.assign(creepMemory, additionalMemory);
              if (this.inQueue(creepMemory) || this.inRoom(creepMemory, amount)) {
                return false;
            Severity: Minor
            Found in src/prototype_room_creepbuilder.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 checkRoleToSpawn has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            Room.prototype.checkRoleToSpawn = function(role, amount, targetId, targetRoom, level, base, additionalMemory = {}) {
            Severity: Major
            Found in src/prototype_room_creepbuilder.js - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (room.terminal.store[mineral] > 30) {
                          boostConfig.resources.push(mineral);
                        }
              Severity: Major
              Found in src/prototype_room_creepbuilder.js - About 45 mins to fix

                Function creepMem has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                Room.prototype.creepMem = function(role, targetId, targetRoom, level, base) {
                Severity: Minor
                Found in src/prototype_room_creepbuilder.js - About 35 mins to fix

                  Function spawnCreateCreep has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Room.prototype.spawnCreateCreep = function(creep) {
                    const spawns = this.findSpawnsNotSpawning();
                    if (spawns.length === 0) {
                      return false;
                    }
                  Severity: Minor
                  Found in src/prototype_room_creepbuilder.js - About 35 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

                  Avoid too many return statements within this function.
                  Open

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

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

                    Room.prototype.inRoom = function(creepMemory, amount = 1) {
                      if (amount === 0) {
                        return false;
                      }
                      const creepsSpawning = this.getSpawningCreeps();
                    Severity: Minor
                    Found in src/prototype_room_creepbuilder.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