File pathFinder.js
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
var ocargo = ocargo || {};
ocargo.PathFinder = function(model) {
Function getOptimalPath
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function getOptimalPath(nodes, destinations) {
// Brute force Travelling Salesman implementation, using A* to determine the connection lengths
// If the map size increases or lots of destinations are required, it may need to be rethought
let hash = {};
function getPathBetweenNodes(node1, node2) {
- 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 getOptimalPath
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getOptimalPath(nodes, destinations) {
// Brute force Travelling Salesman implementation, using A* to determine the connection lengths
// If the map size increases or lots of destinations are required, it may need to be rethought
let hash = {};
function getPathBetweenNodes(node1, node2) {
Function getScore
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
ocargo.PathFinder.prototype.getScore = function() {
let routeCoins = {};
let instrCoins = {};
let performance= "";
Function PriorityQueue
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function PriorityQueue() {
this.push = function(node, score) {
if (this.head == null) {
this.head = new QueueLink(node, score);
} else if (this.head.score > score) {
- 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 aStar
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function aStar(origin, destination, nodes) {
const end = destination; // Nodes already visited.
let current;
const start = origin;
let closedSet = {}; // The neighbours yet to be evaluated.
Function aStar
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function aStar(origin, destination, nodes) {
const end = destination; // Nodes already visited.
let current;
const start = origin;
let closedSet = {}; // The neighbours yet to be evaluated.
- 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 PriorityQueue
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function PriorityQueue() {
this.push = function(node, score) {
if (this.head == null) {
this.head = new QueueLink(node, score);
} else if (this.head.score > score) {
Function getScore
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
ocargo.PathFinder.prototype.getScore = function() {
let routeCoins = {};
let instrCoins = {};
let performance= "";
- 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 getLength
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ocargo.PathFinder.prototype.getLength = function(stack) {
let total = 0;
if (!stack) {
return total;
}
- 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 PathFinder
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
ocargo.PathFinder = function(model) {
this.van = model.van;
this.nodes = model.map.nodes;
this.destinations = model.map.destinations;
- 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"