ocadotechnology/rapid-router

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

Summary

Maintainability
F
1 wk
Test Coverage

File model.js has 493 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var ocargo = ocargo || {};

ocargo.Model = function(nodeData, origin, destinations, trafficLightData, cowData, maxFuel) {
Severity: Minor
Found in game/static/game/js/model.js - About 7 hrs to fix

    Function moveVan has 129 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ocargo.Model.prototype.moveVan = function(nextNode, action) {
        // Crash?
        let currentNodeHasCow = this.getCowForNode(this.van.getPosition().currentNode, [ocargo.Cow.ACTIVE, ocargo.Cow.READY]);
    
        if (currentNodeHasCow) {
    Severity: Major
    Found in game/static/game/js/model.js - About 5 hrs to fix

      Function programExecutionEnded has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ocargo.Model.prototype.programExecutionEnded = function () {
          var success;
          var destinations = this.map.getDestinations();
          var failType = 'OUT_OF_INSTRUCTIONS';
          var failMessage = gettext('The van ran out of instructions before it reached a destination. '  +
      Severity: Major
      Found in game/static/game/js/model.js - About 4 hrs to fix

        Function getCowForNode has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        ocargo.Model.prototype.getCowForNode = function(node, state) {
            var jsonCoordinate = JSON.stringify(node.coordinate);
            for(var i = 0; i < this.cows.length; i++) {
                var cow = this.cows[i];
                if (jsonCoordinate in cow.activeNodes) {
        Severity: Minor
        Found in game/static/game/js/model.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 programExecutionEnded has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        ocargo.Model.prototype.programExecutionEnded = function () {
            var success;
            var destinations = this.map.getDestinations();
            var failType = 'OUT_OF_INSTRUCTIONS';
            var failMessage = gettext('The van ran out of instructions before it reached a destination. '  +
        Severity: Minor
        Found in game/static/game/js/model.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 deliver has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ocargo.Model.prototype.deliver = function() {
            var destination = this.getDestinationForNode(this.van.getPosition().currentNode);
            if(destination) {
                if(destination.visited){
                    //fail if already visited
        Severity: Minor
        Found in game/static/game/js/model.js - About 1 hr to fix

          Function handleCrash has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function handleCrash(model, popupMessage, vanAction, actionDescription) {
                  model.van.crashStatus = 'CRASHED';
                  ocargo.game.sendAttempt(0);
          
                  ocargo.animation.appendAnimation({
          Severity: Minor
          Found in game/static/game/js/model.js - About 1 hr to fix

            Function Model has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            ocargo.Model = function(nodeData, origin, destinations, trafficLightData, cowData, maxFuel) {
            Severity: Minor
            Found in game/static/game/js/model.js - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                  return true;
              Severity: Major
              Found in game/static/game/js/model.js - About 30 mins to fix

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

                ocargo.Model.prototype.moveVan = function(nextNode, action) {
                    // Crash?
                    let currentNodeHasCow = this.getCowForNode(this.van.getPosition().currentNode, [ocargo.Cow.ACTIVE, ocargo.Cow.READY]);
                
                    if (currentNodeHasCow) {
                Severity: Minor
                Found in game/static/game/js/model.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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.isTrafficLightGreen = function() {
                    this.observe('traffic light green');
                    var light = this.getTrafficLightForNode(this.van.getPosition());
                    return (light !== null && light.getState() === ocargo.TrafficLight.GREEN);
                };
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 2 hrs to fix
                game/static/game/js/model.js on lines 96..100

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 91.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.isTrafficLightRed = function() {
                    this.observe('traffic light red');
                    var light = this.getTrafficLightForNode(this.van.getPosition());
                    return (light !== null && light.getState() === ocargo.TrafficLight.RED);
                };
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 2 hrs to fix
                game/static/game/js/model.js on lines 102..106

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 91.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        ocargo.event.sendEvent("LevelThroughRedLight", { levelName: LEVEL_NAME,
                                                                         defaultLevel: DEFAULT_LEVEL,
                                                                         workspace: ocargo.blocklyControl.serialize(),
                                                                         failures: this.failures,
                                                                         pythonWorkspace: ocargo.pythonControl.getCode() });
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/model.js on lines 156..160

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 70.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        ocargo.event.sendEvent("LevelRunOutOfFuel", { levelName: LEVEL_NAME,
                                                                      defaultLevel: DEFAULT_LEVEL,
                                                                      workspace: ocargo.blocklyControl.serialize(),
                                                                      failures: this.failures,
                                                                      pythonWorkspace: ocargo.pythonControl.getCode() });
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/model.js on lines 196..200

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 70.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                        ocargo.event.sendEvent("LevelFailure", {
                            levelName: LEVEL_NAME,
                            defaultLevel: DEFAULT_LEVEL,
                            workspace: ocargo.blocklyControl.serialize(),
                            failures: this.failures,
                Severity: Major
                Found in game/static/game/js/model.js and 2 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 377..381
                game/static/game/js/model.js on lines 444..450

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                            ocargo.event.sendEvent("LevelUndeliveredDestinations", {
                                levelName: LEVEL_NAME,
                                defaultLevel: DEFAULT_LEVEL,
                                workspace: ocargo.blocklyControl.serialize(),
                                failures: this.failures,
                Severity: Major
                Found in game/static/game/js/model.js and 2 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 377..381
                game/static/game/js/model.js on lines 527..533

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                            ocargo.event.sendEvent("LevelAlreadyDelivered", { levelName: LEVEL_NAME,
                                                                              defaultLevel: DEFAULT_LEVEL,
                                                                              workspace: ocargo.blocklyControl.serialize(),
                                                                              failures: this.failures,
                                                                              pythonWorkspace: ocargo.pythonControl.getCode() });
                Severity: Major
                Found in game/static/game/js/model.js and 2 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 444..450
                game/static/game/js/model.js on lines 527..533

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.turnLeft = function() {
                    var nextNode = this.map.isRoadLeft(this.van.getPosition());
                    return this.moveVan(nextNode, 'TURN_LEFT');
                };
                Severity: Major
                Found in game/static/game/js/model.js and 2 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 311..314
                game/static/game/js/model.js on lines 321..324

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 66.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.turnRight = function() {
                    var nextNode = this.map.isRoadRight(this.van.getPosition());
                    return this.moveVan(nextNode, 'TURN_RIGHT');
                };
                Severity: Major
                Found in game/static/game/js/model.js and 2 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 311..314
                game/static/game/js/model.js on lines 316..319

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 66.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.moveForwards = function() {
                    var nextNode = this.map.isRoadForward(this.van.getPosition());
                    return this.moveVan(nextNode, 'FORWARD');
                };
                Severity: Major
                Found in game/static/game/js/model.js and 2 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 316..319
                game/static/game/js/model.js on lines 321..324

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 66.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.isRoadRight = function() {
                    this.observe('right');
                    return (this.map.isRoadRight(this.van.getPosition()) !== null);
                };
                Severity: Major
                Found in game/static/game/js/model.js and 3 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 70..73
                game/static/game/js/model.js on lines 75..78
                game/static/game/js/model.js on lines 85..88

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 65.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.isDeadEnd = function() {
                    this.observe('dead end');
                    return (this.map.isDeadEnd(this.van.getPosition()) !== null);
                };
                Severity: Major
                Found in game/static/game/js/model.js and 3 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 70..73
                game/static/game/js/model.js on lines 75..78
                game/static/game/js/model.js on lines 80..83

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 65.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.isRoadForward = function() {
                    this.observe('forward');
                    return (this.map.isRoadForward(this.van.getPosition()) !== null);
                };
                Severity: Major
                Found in game/static/game/js/model.js and 3 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 75..78
                game/static/game/js/model.js on lines 80..83
                game/static/game/js/model.js on lines 85..88

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 65.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                ocargo.Model.prototype.isRoadLeft = function() {
                    this.observe('left');
                    return (this.map.isRoadLeft(this.van.getPosition()) !== null);
                };
                Severity: Major
                Found in game/static/game/js/model.js and 3 other locations - About 1 hr to fix
                game/static/game/js/model.js on lines 70..73
                game/static/game/js/model.js on lines 80..83
                game/static/game/js/model.js on lines 85..88

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 65.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        ocargo.animation.appendAnimation({
                            type: 'popup',
                            popupType: 'FAIL',
                            failSubtype: 'THROUGH_RED_LIGHT',
                            popupMessage: gettext('Uh oh, you just sent the van through a red light! Stick to the Highway ' +
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/model.js on lines 353..361

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    for(var i = 0; i < cowData.length; i++) {
                        this.cows.push(new ocargo.Cow(i, cowData[i], this.map.nodes));
                    }
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/model.js on lines 10..12

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    for(var i = 0; i < trafficLightData.length; i++) {
                        this.trafficLights.push(new ocargo.TrafficLight(i, trafficLightData[i], this.map.nodes));
                    }
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/model.js on lines 15..17

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            ocargo.animation.appendAnimation({
                                type: 'popup',
                                popupType: 'FAIL',
                                failSubtype: 'ALREADY_DELIVERED',
                                popupMessage: gettext('You have already delivered to that destination! You must only deliver ' +
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/model.js on lines 202..210

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        ocargo.animation.appendAnimation({
                            type: 'popup',
                            popupType: 'FAIL',
                            failSubtype: 'OUT_OF_FUEL',
                            popupMessage: gettext('You ran out of fuel! Try to find a shorter route to the destination.'),
                Severity: Major
                Found in game/static/game/js/model.js and 1 other location - About 1 hr to fix
                game/static/game/js/program.js on lines 48..57

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 60.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    for (var j = 0; j < this.cows.length; j++) {
                        this.cows[j].reset();
                    }
                Severity: Minor
                Found in game/static/game/js/model.js and 1 other location - About 40 mins to fix
                game/static/game/js/model.js on lines 39..41

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 49.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    for (var j = 0; j < this.trafficLights.length; j++) {
                        this.trafficLights[j].reset();
                    }
                Severity: Minor
                Found in game/static/game/js/model.js and 1 other location - About 40 mins to fix
                game/static/game/js/model.js on lines 43..45

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 49.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        ocargo.animation.appendAnimation({
                            type: 'callable',
                            functionType: 'playSound',
                            functionCall: ocargo.sound.win,
                            description: 'win sound'
                Severity: Minor
                Found in game/static/game/js/model.js and 1 other location - About 35 mins to fix
                game/static/game/js/model.js on lines 520..525

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 46.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        ocargo.animation.appendAnimation({
                            type: 'callable',
                            functionType: 'playSound',
                            functionCall: ocargo.sound.failure,
                            description: 'failure sound'
                Severity: Minor
                Found in game/static/game/js/model.js and 1 other location - About 35 mins to fix
                game/static/game/js/model.js on lines 489..494

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 46.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status