Mirroar/hivemind

View on GitHub
src/role/mule.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function pickupResources has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    pickupResources(creep: MuleCreep) {
        const originRoom = this.tradeRoute.getOrigin();
        if (creep.pos.roomName !== originRoom) {
            // Move back to spawn room.
            this.followRoomPath(creep);
Severity: Minor
Found in src/role/mule.ts - About 1 hr to fix

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

        pickupResources(creep: MuleCreep) {
            const originRoom = this.tradeRoute.getOrigin();
            if (creep.pos.roomName !== originRoom) {
                // Move back to spawn room.
                this.followRoomPath(creep);
    Severity: Minor
    Found in src/role/mule.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

    Function followRoomPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        followRoomPath(creep: MuleCreep) {
            if (!creep.memory.roomPath) {
                const targetPosition = new RoomPosition(25, 25, creep.memory.delivering ? this.tradeRoute.getTarget() : this.tradeRoute.getOrigin());
                creep.interRoomTravel(targetPosition);
                return;
    Severity: Minor
    Found in src/role/mule.ts - About 45 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

    Function deliverResources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        deliverResources(creep: MuleCreep) {
            // @todo If delivering energy to one of our own rooms that doesn't have
            // a storage, use transporter logic to drop off the energy, or even
            // act as a temporary container until energy is used up.
            const targetRoom = this.tradeRoute.getTarget();
    Severity: Minor
    Found in src/role/mule.ts - About 45 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;
    Severity: Major
    Found in src/role/mule.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return;
      Severity: Major
      Found in src/role/mule.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                if (!target) return;
        Severity: Major
        Found in src/role/mule.ts - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status