Mirroar/hivemind

View on GitHub
src/empire/remote-mine-prioritizer.ts

Summary

Maintainability
C
1 day
Test Coverage

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

    getRemoteMiningSourceRooms(): Record<string, SourceRoomAvailability> {
        const sourceRooms: Record<string, SourceRoomAvailability> = {};

        // Determine how much remote mining each room can handle.
        for (const room of Game.myRooms) {
Severity: Minor
Found in src/empire/remote-mine-prioritizer.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 getRoomsToMine has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    getRoomsToMine(maxAmount: number): {rooms: string[]; maxRooms: number} {
        const result: string[] = [];
        const sourceRooms = this.getRemoteMiningSourceRooms();

        // Create ordered list of best harvest rooms.
Severity: Minor
Found in src/empire/remote-mine-prioritizer.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

Consider simplifying this complex logical expression.
Open

                    if (
                        Game.shard.name === 'shardSeason'
                        && roomName !== 'E34N16'
                        && roomName !== 'E34N15'
                        && roomName !== 'E36N14'
Severity: Critical
Found in src/empire/remote-mine-prioritizer.ts - About 1 hr to fix

    Function getRemoteMiningSourceRooms has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getRemoteMiningSourceRooms(): Record<string, SourceRoomAvailability> {
            const sourceRooms: Record<string, SourceRoomAvailability> = {};
    
            // Determine how much remote mining each room can handle.
            for (const room of Game.myRooms) {
    Severity: Minor
    Found in src/empire/remote-mine-prioritizer.ts - About 1 hr to fix

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

          getRoomsToMine(maxAmount: number): {rooms: string[]; maxRooms: number} {
              const result: string[] = [];
              const sourceRooms = this.getRemoteMiningSourceRooms();
      
              // Create ordered list of best harvest rooms.
      Severity: Minor
      Found in src/empire/remote-mine-prioritizer.ts - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status