Mirroar/hivemind

View on GitHub
src/operation/remote-mining.ts

Summary

Maintainability
D
2 days
Test Coverage

File remote-mining.ts has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global RoomPosition SOURCE_ENERGY_CAPACITY CARRY_CAPACITY
SOURCE_ENERGY_NEUTRAL_CAPACITY ENERGY_REGEN_TIME CONTROLLER_RESERVE_MAX
HARVEST_POWER LOOK_STRUCTURES STRUCTURE_CONTAINER */

import cache from 'utils/cache';
Severity: Minor
Found in src/operation/remote-mining.ts - About 5 hrs to fix

    RemoteMiningOperation has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class RemoteMiningOperation extends Operation {
        protected memory: RemoteMiningOperationMemory;
        protected pathManager: PathManager;
    
        /**
    Severity: Minor
    Found in src/operation/remote-mining.ts - About 3 hrs to fix

      Function getDismantlePositions has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          getDismantlePositions(sourceLocation: string): RoomPosition[] {
              if (!hivemind.segmentMemory.isReady()) return [];
      
              // No dismantlers for SK rooms, they get confused easily...
              const roomIntel = getRoomIntel(this.roomName);
      Severity: Minor
      Found in src/operation/remote-mining.ts - 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 getPaths has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getPaths() {
              return cache.inObject(this, 'getPaths', 0, () => {
                  if (!hivemind.segmentMemory.isReady()) return {};
      
                  const roomIntel = getRoomIntel(this.roomName);
      Severity: Major
      Found in src/operation/remote-mining.ts - About 2 hrs to fix

        Function getDismantlePositions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getDismantlePositions(sourceLocation: string): RoomPosition[] {
                if (!hivemind.segmentMemory.isReady()) return [];
        
                // No dismantlers for SK rooms, they get confused easily...
                const roomIntel = getRoomIntel(this.roomName);
        Severity: Minor
        Found in src/operation/remote-mining.ts - About 1 hr to fix

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

              getTotalEnemyData(): EnemyData {
                  const totalEnemyData: EnemyData = {
                      parts: {},
                      damage: 0,
                      heal: 0,
          Severity: Minor
          Found in src/operation/remote-mining.ts - 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

          Avoid too many return statements within this function.
          Open

                          return true;
          Severity: Major
          Found in src/operation/remote-mining.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        if (!containerPosition) return false;
            Severity: Major
            Found in src/operation/remote-mining.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return false;
              Severity: Major
              Found in src/operation/remote-mining.ts - About 30 mins to fix

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

                    needsDismantler(sourceLocation?: string): boolean {
                        if (!hivemind.segmentMemory.isReady()) return false;
                        if (sourceLocation) return this.getDismantlePositions(sourceLocation).length > 0;
                
                        for (const pos of this.getSourcePositions()) {
                Severity: Minor
                Found in src/operation/remote-mining.ts - 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