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.
- Read upRead up
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;
- Read upRead up
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;
- Read upRead up
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;
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 {};
- Read upRead up
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[])) {
- Read upRead up
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"