File BarnesHutSolver.js
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Barnes Hut Solver
*/
class BarnesHutSolver {
/**
Function _formBarnesHutTree
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
_formBarnesHutTree(nodes, nodeIndices) {
let node;
let nodeCount = nodeIndices.length;
let minX = nodes[nodeIndices[0]].x;
- 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 _formBarnesHutTree
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
_formBarnesHutTree(nodes, nodeIndices) {
let node;
let nodeCount = nodeIndices.length;
let minX = nodes[nodeIndices[0]].x;
Function _insertRegion
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
_insertRegion(parentBranch, region) {
let minX, maxX, minY, maxY;
let childSize = 0.5 * parentBranch.size;
switch (region) {
case "NW":
Function _getForceContribution
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
_getForceContribution(parentBranch, node) {
// we get no force contribution from an empty region
if (parentBranch.childrenCount > 0) {
let dx, dy, distance;
- 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 _placeInTree
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_placeInTree(parentBranch, node, skipMassUpdate) {
if (skipMassUpdate != true || skipMassUpdate === undefined) {
// update the mass of the branch.
this._updateBranchMass(parentBranch, node);
}
- 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 _drawBranch
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_drawBranch(branch, ctx, color) {
if (color === undefined) {
color = "#FF0000";
}
Function solve
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
solve() {
if (this.options.gravitationalConstant !== 0 && this.physicsBody.physicsNodeIndices.length > 0) {
let node;
let nodes = this.body.nodes;
let nodeIndices = this.physicsBody.physicsNodeIndices;
- 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 _drawBranch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_drawBranch(branch, ctx, color) {
if (color === undefined) {
color = "#FF0000";
}
- 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"