Mirroar/hivemind

View on GitHub
src/creep/body-builder.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function generateSortedParts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private generateSortedParts(partCounts: Partial<Record<BodyPartConstant, number>>): BodyPartConstant[] {
        // @todo Create array of non-move parts in sensible order.
        const body: BodyPartConstant[] = [];

        // Start with tough parts.
Severity: Minor
Found in src/creep/body-builder.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 interweaveMoveParts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private interweaveMoveParts(body: BodyPartConstant[], moveParts: number): BodyPartConstant[] {
        const moveStrength = this.getMovePartStrength();
        let totalFatigue = _.sum(body, part => this.getGeneratedFatigue(part));
        let totalMovePower = moveParts * moveStrength;

Severity: Minor
Found in src/creep/body-builder.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 calculatePartCounts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private calculatePartCounts(): PartCounts {
        const partCounts: PartCounts = {[MOVE]: 0};
        let currentSize = 0;
        let currentCost = 0;

Severity: Minor
Found in src/creep/body-builder.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 calculatePartCounts has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private calculatePartCounts(): PartCounts {
        const partCounts: PartCounts = {[MOVE]: 0};
        let currentSize = 0;
        let currentCost = 0;

Severity: Minor
Found in src/creep/body-builder.ts - About 1 hr to fix

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

        private normalizeWeights(weights: BodyWeights): BodyWeights {
            const total = _.sum(_.filter(weights, (weight, partType) => weight > 0 && partType !== MOVE));
    
            if (total <= 0) return {};
    
    
    Severity: Minor
    Found in src/creep/body-builder.ts - 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

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

        private getNextBodyPart(partCounts: PartCounts): BodyPartConstant {
            const currentWeights = this.normalizeWeights(partCounts);
    
            let fallbackPart: BodyPartConstant = null;
            for (const part of (_.keys(this.weights) as BodyPartConstant[])) {
    Severity: Minor
    Found in src/creep/body-builder.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