ocadotechnology/rapid-router

View on GitHub
game/static/game/js/pathFinder.js

Summary

Maintainability
D
2 days
Test Coverage

File pathFinder.js has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var ocargo = ocargo || {};

ocargo.PathFinder = function(model) {
Severity: Minor
Found in game/static/game/js/pathFinder.js - About 3 hrs to fix

    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) {
    Severity: Minor
    Found in game/static/game/js/pathFinder.js - About 3 hrs 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 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) {
    Severity: Major
    Found in game/static/game/js/pathFinder.js - About 2 hrs to fix

      Function getScore has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ocargo.PathFinder.prototype.getScore = function() {
          let routeCoins = {};
          let instrCoins = {};
          let performance= "";
      
      
      Severity: Major
      Found in game/static/game/js/pathFinder.js - About 2 hrs to fix

        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) {
        Severity: Minor
        Found in game/static/game/js/pathFinder.js - About 2 hrs 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 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.
        Severity: Major
        Found in game/static/game/js/pathFinder.js - About 2 hrs to fix

          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.
          Severity: Minor
          Found in game/static/game/js/pathFinder.js - 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 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) {
          Severity: Minor
          Found in game/static/game/js/pathFinder.js - About 1 hr to fix

            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= "";
            
            
            Severity: Minor
            Found in game/static/game/js/pathFinder.js - 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 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;
                }
            Severity: Minor
            Found in game/static/game/js/pathFinder.js - 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 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;
            
            
            Severity: Minor
            Found in game/static/game/js/pathFinder.js - 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