TooAngel/screeps

View on GitHub

Showing 492 of 594 total issues

File prototype_room_external.js has 610 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const {getMyRoomWithinRange, findMyRoomsSortByDistance} = require('./helper_findMyRooms');
const {addToReputation, initPlayer, addRoomToPlayer} = require('./diplomacy');
const {haveActiveQuest} = require('./quests_player');
Severity: Major
Found in src/prototype_room_external.js - About 1 day to fix

    File prototype_room_my.js has 592 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const {findMyRoomsSortByDistance} = require('./helper_findMyRooms');
    const {addToReputation} = require('./diplomacy');
    const {isFriend} = require('./brain_squadmanager');
    Severity: Major
    Found in src/prototype_room_my.js - About 1 day to fix

      Function exports has 232 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(grunt) {
        let account;
        try {
          account = require('./account.screeps.com'); // eslint-disable-line global-require
        } catch (e) {
      Severity: Major
      Found in Gruntfile.js - About 1 day to fix

        File prototype_creep_resources.js has 526 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        Creep.pickableResources = function(creep) {
          return (object) => creep.pos.isNearTo(object);
        };
        Severity: Major
        Found in src/prototype_creep_resources.js - About 1 day to fix

          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

            File prototype_room_init.js has 441 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict';
            
            // TODO this does not need to be on the Room object
            Room.prototype.setPosition = function(type, pos, value = config.layout.structureAvoid, positionType = 'structure', firstStructure = false) {
              this.debugLog('baseBuilding', `Increasing ${pos} ${type} ${positionType} with ${value}`);
            Severity: Minor
            Found in src/prototype_room_init.js - About 6 hrs to fix

              Function action has a Cognitive Complexity of 35 (exceeds 5 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: Minor
              Found in src/role_atkeeper.js - About 5 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 a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

              roles.atkeepermelee.action = function(creep) {
                // TODO Untested
                creep.spawnReplacement();
                creep.setNextSpawn();
                creep.memory.canHeal = creep.getActiveBodyparts(HEAL) > 0;
              Severity: Minor
              Found in src/role_atkeepermelee.js - About 5 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 prototype_creep.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              'use strict';
              
              const {addToReputation} = require('./diplomacy');
              
              /**
              Severity: Minor
              Found in src/prototype_creep.js - About 4 hrs to fix

                Function setLabs has a Cognitive Complexity of 32 (exceeds 5 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 4 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 checkBlockedPath has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                Room.prototype.checkBlockedPath = function() {
                  for (const pathName of Object.keys(this.getMemoryPaths())) {
                    const path = this.getMemoryPath(pathName) || {};
                    for (const pos of path) {
                      const roomPos = new RoomPosition(pos.x, pos.y, this.name);
                Severity: Minor
                Found in src/prototype_room_external.js - About 4 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 prototype_room_basebuilder.js has 352 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                'use strict';
                
                /**
                 * posIsIn position is in array
                 *
                Severity: Minor
                Found in src/prototype_room_basebuilder.js - About 4 hrs to fix

                  Function showSearch has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                  Open

                    showSearch(search) {
                      if (search) {
                        const rv = {};
                        const getRV = (pos) => {
                          if (!rv[pos.roomName]) {
                  Severity: Minor
                  Found in src/visualizer.js - About 4 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 prototype_creep_startup_tasks.js has 349 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  'use strict';
                  
                  Creep.execute = function(creep, methods) {
                    for (const method of methods) {
                      if (method(creep)) {
                  Severity: Minor
                  Found in src/prototype_creep_startup_tasks.js - About 4 hrs to fix

                    File role_mineral.js has 346 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    'use strict';
                    
                    /*
                     * mineral manages the mineral distributions
                     *
                    Severity: Minor
                    Found in src/role_mineral.js - About 4 hrs to fix

                      Function showCreeps has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

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

                      function updateCostMatrixFromPositions(room, costMatrix) {
                        for (const positionType of Object.keys(room.data.positions)) {
                          if (positionType === 'pathEndLevel' || positionType === 'version') {
                            continue;
                          }
                      Severity: Minor
                      Found in src/prototype_room_costmatrix.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 sellByOwnOrders has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Room.prototype.sellByOwnOrders = function(resource, sellAmount) {
                        const avgBuyPrice = brain.getMarketOrderAverage(ORDER_BUY, resource);
                        const avgSellPrice = brain.getMarketOrderAverage(ORDER_SELL, resource);
                        const mySellPrice = Math.max((avgBuyPrice || 1) * config.market.sellOrderPriceMultiplicand, config.market.minSellPrice);
                        if (!avgSellPrice || mySellPrice <= avgSellPrice) {
                      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 preMove has a Cognitive Complexity of 27 (exceeds 5 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 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 orderMinerals has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Room.prototype.orderMinerals = function() {
                        if (this.executeEveryTicks(20)) {
                          const room = this;
                      
                          for (const mineral of baseMinerals) {
                      Severity: Minor
                      Found in src/prototype_room_mineral.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

                      Severity
                      Category
                      Status
                      Source
                      Language