ocadotechnology/rapid-router

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

Summary

Maintainability
F
2 wks
Test Coverage

File game.js has 1137 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'

var ocargo = ocargo || {}

ocargo.Game = function () {
Severity: Major
Found in game/static/game/js/game.js - About 2 days to fix

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

    ocargo.Game.prototype._setupTabs = function () {
      this.tabs = []
    
      this.tabs.blockly = new ocargo.Tab(
        $('#blockly_radio'),
    Severity: Major
    Found in game/static/game/js/game.js - About 4 hrs to fix

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

      ocargo.Game.prototype.setup = function () {
        gameUpdateBlockLanguage(navigator.language.toLowerCase())
      
        if(new Date().getMonth() === 11) {
          $("#paper").css('background-color', '#eef7ff')
      Severity: Major
      Found in game/static/game/js/game.js - About 4 hrs to fix

        Function _setupPythonTab has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ocargo.Game.prototype._setupPythonTab = function () {
          $('#clear_console').click(
            function (e) {
              $('#consoleOutput').text('')
            }.bind(this)
        Severity: Major
        Found in game/static/game/js/game.js - About 3 hrs to fix

          Function _setupLoadTab has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ocargo.Game.prototype._setupLoadTab = function () {
            var selectedWorkspace = null
            this.tabs.load.setOnChange(
              function () {
                this.changeTabSelectionTo(this.tabs.load)
          Severity: Major
          Found in game/static/game/js/game.js - About 3 hrs to fix

            Function _setupSaveTab has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ocargo.Game.prototype._setupSaveTab = function () {
              var selectedWorkspace = null
            
              this.tabs.save.setOnChange(
                function () {
            Severity: Major
            Found in game/static/game/js/game.js - About 3 hrs to fix

              Function setup has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              ocargo.Game.prototype.setup = function () {
                gameUpdateBlockLanguage(navigator.language.toLowerCase())
              
                if(new Date().getMonth() === 11) {
                  $("#paper").css('background-color', '#eef7ff')
              Severity: Minor
              Found in game/static/game/js/game.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 runProgramAndPrepareAnimation has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ocargo.Game.prototype.runProgramAndPrepareAnimation = function (blocks) {
                this.reset()
                let code = ocargo.pythonControl.getCode()
                ocargo.event.sendEvent('PlayButtonPressed', {
                  levelName: LEVEL_NAME,
              Severity: Major
              Found in game/static/game/js/game.js - About 2 hrs to fix

                Function _setupConsoleSliderListeners has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ocargo.Game.prototype._setupConsoleSliderListeners = function () {
                  let tabsWidth = $('#tabs').width()
                
                  let startEvents = ['mousedown', 'touchstart']
                  let moveEvents = ['mousemove', 'touchmove']
                Severity: Major
                Found in game/static/game/js/game.js - About 2 hrs to fix

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

                  ocargo.Game.prototype._setupConsoleSliderListeners = function () {
                    let tabsWidth = $('#tabs').width()
                  
                    let startEvents = ['mousedown', 'touchstart']
                    let moveEvents = ['mousemove', 'touchmove']
                  Severity: Minor
                  Found in game/static/game/js/game.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 _setupConsoleLogViewSliderListeners has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ocargo.Game.prototype._setupConsoleLogViewSliderListeners = function () {
                    let startEvents = ['mousedown', 'touchstart']
                    let moveEvents = ['mousemove', 'touchmove']
                    let endEvents = ['mouseup', 'touchend', 'touchcancel']
                  
                  
                  Severity: Minor
                  Found in game/static/game/js/game.js - About 1 hr to fix

                    Function _setupFuelGauge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ocargo.Game.prototype._setupFuelGauge = function (nodes, blocks) {
                      if (FUEL_GAUGE) {
                        document.getElementById('fuelGauge').style.visibility = 'visible'
                    
                        for (var i = 0; i < blocks.length; i++) {
                    Severity: Minor
                    Found in game/static/game/js/game.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 sendAttempt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    ocargo.Game.prototype.sendAttempt = function (score) {
                      function csrfSafeMethod (method) {
                        // these HTTP methods do not require CSRF protection
                        return /^(GET|HEAD|OPTIONS|TRACE)$/.test(method)
                      }
                    Severity: Minor
                    Found in game/static/game/js/game.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 _setupPythonViewSliderListeners has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ocargo.Game.prototype._setupPythonViewSliderListeners = function () {
                      let startEvents = ['mousedown', 'touchstart']
                      let moveEvents = ['mousemove', 'touchmove']
                      let endEvents = ['mouseup', 'touchend', 'touchcancel']
                    
                    
                    Severity: Minor
                    Found in game/static/game/js/game.js - About 1 hr to fix

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

                      ocargo.Game.prototype._setupDirectDriveListeners = function () {
                        var manoeuvreCallback = function () {
                          this.drawing.scrollToShowCharacter()
                          this.onStopControls()
                        }.bind(this)
                      Severity: Minor
                      Found in game/static/game/js/game.js - About 1 hr to fix

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

                          function saveWorkspace () {
                            var newName = $('#workspaceNameInput').val()
                            if (newName && newName !== '') {
                              var table = $('#saveWorkspaceTable')
                              var existingID = null
                        Severity: Minor
                        Found in game/static/game/js/game.js - About 1 hr to fix

                          Function sendAttempt has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          ocargo.Game.prototype.sendAttempt = function (score) {
                            function csrfSafeMethod (method) {
                              // these HTTP methods do not require CSRF protection
                              return /^(GET|HEAD|OPTIONS|TRACE)$/.test(method)
                            }
                          Severity: Minor
                          Found in game/static/game/js/game.js - About 1 hr to fix

                            Function _setupSaveTab has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                            ocargo.Game.prototype._setupSaveTab = function () {
                              var selectedWorkspace = null
                            
                              this.tabs.save.setOnChange(
                                function () {
                            Severity: Minor
                            Found in game/static/game/js/game.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 _setupFastTab has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            ocargo.Game.prototype._setupFastTab = function () {
                              this.tabs.fast.setOnChange(
                                function () {
                                  var flipFastSlow = function () {
                                    if (this.tabs.fast.isInState('slow')) {
                            Severity: Minor
                            Found in game/static/game/js/game.js - About 1 hr to fix

                              Function _setupSolutionTab has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                              ocargo.Game.prototype._setupSolutionTab = function () {
                                this.tabs.solution.setOnChange(
                                  function () {
                                    this._goToWorkspace()
                              
                              
                              Severity: Minor
                              Found in game/static/game/js/game.js - About 55 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 _setupFastTab has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                              ocargo.Game.prototype._setupFastTab = function () {
                                this.tabs.fast.setOnChange(
                                  function () {
                                    var flipFastSlow = function () {
                                      if (this.tabs.fast.isInState('slow')) {
                              Severity: Minor
                              Found in game/static/game/js/game.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

                              Consider simplifying this complex logical expression.
                              Open

                                  if (
                                    (!workspace.blockly_enabled && !workspace.python_enabled) ||
                                    (workspace.blockly_enabled && BLOCKLY_ENABLED) ||
                                    (workspace.python_enabled && PYTHON_ENABLED)
                                  ) {
                              Severity: Major
                              Found in game/static/game/js/game.js - About 40 mins to fix

                                Function _populateTable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                ocargo.Game.prototype._populateTable = function (tableName, workspaces) {
                                  var table = $('#' + tableName),
                                    sortedWorkspaces = []
                                
                                  // Remove click listeners to avoid memory leak and remove all rows
                                Severity: Minor
                                Found in game/static/game/js/game.js - About 35 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 _setupStepTab has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                ocargo.Game.prototype._setupStepTab = function () {
                                  this.tabs.step.setOnChange(
                                    function () {
                                      if (this.tabs.play.isInState('readyToPlay')) {
                                        this._resetAndPrepareAnimation()
                                Severity: Minor
                                Found in game/static/game/js/game.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

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

                                ocargo.Game.prototype._setupConsoleLogViewSliderListeners = function () {
                                  let startEvents = ['mousedown', 'touchstart']
                                  let moveEvents = ['mousemove', 'touchmove']
                                  let endEvents = ['mouseup', 'touchend', 'touchcancel']
                                
                                
                                Severity: Minor
                                Found in game/static/game/js/game.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

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

                                ocargo.Game.prototype._setupPythonViewSliderListeners = function () {
                                  let startEvents = ['mousedown', 'touchstart']
                                  let moveEvents = ['mousemove', 'touchmove']
                                  let endEvents = ['mouseup', 'touchend', 'touchcancel']
                                
                                
                                Severity: Minor
                                Found in game/static/game/js/game.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

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

                                ocargo.Game.prototype._setupLoadTab = function () {
                                  var selectedWorkspace = null
                                  this.tabs.load.setOnChange(
                                    function () {
                                      this.changeTabSelectionTo(this.tabs.load)
                                Severity: Minor
                                Found in game/static/game/js/game.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.Game.prototype.onSlowControls = function () {
                                  this.disallowCodeChanges()
                                
                                  document.getElementById('direct_drive').style.visibility = 'hidden'
                                
                                
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 7 hrs to fix
                                game/static/game/js/game.js on lines 576..590

                                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 193.

                                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.Game.prototype.onFastControls = function () {
                                  this.disallowCodeChanges()
                                
                                  document.getElementById('direct_drive').style.visibility = 'hidden'
                                
                                
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 7 hrs to fix
                                game/static/game/js/game.js on lines 592..606

                                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 193.

                                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

                                  this.tabs.load.setOnChange(
                                    function () {
                                      this.changeTabSelectionTo(this.tabs.load)
                                
                                      selectedWorkspace = null
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 5 hrs to fix
                                game/static/game/js/game.js on lines 1182..1204

                                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 145.

                                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

                                  this.tabs.save.setOnChange(
                                    function () {
                                      this.changeTabSelectionTo(this.tabs.save)
                                
                                      selectedWorkspace = null
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 5 hrs to fix
                                game/static/game/js/game.js on lines 1078..1099

                                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 145.

                                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 < table[0].rows.length; i++) {
                                        var row = table[0].rows[i]
                                        var existingName = row.cells[0].innerHTML
                                        if (existingName === newName) {
                                          existingID = row.getAttribute('value')
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 3 hrs to fix
                                game/static/game/js/level_editor.js on lines 640..647

                                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 100.

                                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

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

                                  let startFunc = function (e) {
                                    moveEvents.map((moveEvent) => wrapper.on(moveEvent, moveFunc))
                                    // disable drag when mouse leaves the wrapper
                                    endEvents.map((endEvent) => wrapper.on(endEvent, endFunc))
                                
                                
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 2 hrs to fix
                                game/static/game/js/game.js on lines 465..472

                                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 92.

                                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

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

                                  let startFunc = function (e) {
                                    moveEvents.map((moveEvent) => wrapper.on(moveEvent, moveFunc))
                                    // disable drag when mouse leaves the wrapper
                                    endEvents.map((endEvent) => wrapper.on(endEvent, endFunc))
                                
                                
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 2 hrs to fix
                                game/static/game/js/game.js on lines 517..524

                                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 92.

                                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

                                  $('#turnRight').click(
                                    function () {
                                      if (ocargo.model.reasonForTermination != 'CRASH') {
                                        this.onPlayControls()
                                        ocargo.blocklyControl.addBlockToEndOfProgram('turn_right')
                                Severity: Major
                                Found in game/static/game/js/game.js and 2 other locations - About 2 hrs to fix
                                game/static/game/js/game.js on lines 315..323
                                game/static/game/js/game.js on lines 324..332

                                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 87.

                                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

                                  $('#moveForward').click(
                                    function () {
                                      if (ocargo.model.reasonForTermination != 'CRASH') {
                                        this.onPlayControls()
                                        ocargo.blocklyControl.addBlockToEndOfProgram('move_forwards')
                                Severity: Major
                                Found in game/static/game/js/game.js and 2 other locations - About 2 hrs to fix
                                game/static/game/js/game.js on lines 324..332
                                game/static/game/js/game.js on lines 333..341

                                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 87.

                                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

                                  $('#turnLeft').click(
                                    function () {
                                      if (ocargo.model.reasonForTermination != 'CRASH') {
                                        this.onPlayControls()
                                        ocargo.blocklyControl.addBlockToEndOfProgram('turn_left')
                                Severity: Major
                                Found in game/static/game/js/game.js and 2 other locations - About 2 hrs to fix
                                game/static/game/js/game.js on lines 315..323
                                game/static/game/js/game.js on lines 333..341

                                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 87.

                                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

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

                                  let endFunc = function (e) {
                                    moveEvents.map((moveEvent) => wrapper.off(moveEvent))
                                    endEvents.map((endEvent) => wrapper.off(endEvent, endFunc))
                                
                                    ocargo.blocklyControl.redrawBlockly()
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 431..436

                                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 74.

                                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

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

                                  let endFunc = function (e) {
                                    moveEvents.map((moveEvent) => wrapper.off(moveEvent))
                                    endEvents.map((endEvent) => wrapper.off(endEvent, endFunc))
                                
                                    ocargo.blocklyControl.redrawBlockly()
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 486..491

                                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 74.

                                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.Game.prototype._setupQuitTab = function () {
                                  this.tabs.quit.setOnChange(
                                    function () {
                                      window.location.href = RETURN_URL
                                    }.bind(this)
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 1325..1331

                                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.Game.prototype._setupNightModeTab = function () {
                                  this.tabs.nightmode.setOnChange(
                                    function () {
                                      window.location.href = FLIP_NIGHT_MODE_URL
                                    }.bind(this)
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 1317..1323

                                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.Game.prototype.onResumeControls = function () {
                                  this.tabs.play.transitTo('running')
                                  buttonTransit("run-code-button", "running")
                                  this.tabs.step.disable()
                                }
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 774..778

                                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 69.

                                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.Game.prototype.onPauseControls = function () {
                                  this.tabs.play.transitTo('paused')
                                  buttonTransit("run-code-button", "paused")
                                  this.tabs.step.enable()
                                }
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 768..772

                                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 69.

                                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

                                  this.tabs.mute
                                    .addState(
                                      'muted',
                                      ocargo.Drawing.imageDir + 'icons/muted.svg',
                                      gettext('Unmute')
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 662..672

                                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 63.

                                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

                                  this.tabs.fast
                                    .addState(
                                      'slow',
                                      ocargo.Drawing.imageDir + 'icons/fast.svg',
                                      gettext('Fast')
                                Severity: Major
                                Found in game/static/game/js/game.js and 1 other location - About 1 hr to fix
                                game/static/game/js/game.js on lines 695..705

                                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 63.

                                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

                                        error: function (xhr, errmsg, err) {
                                          console.error(
                                            xhr.status + ': ' + errmsg + ' ' + err + ' ' + xhr.responseText
                                          )
                                        }.bind(this)
                                Severity: Minor
                                Found in game/static/game/js/game.js and 1 other location - About 50 mins to fix
                                game/static/game/js/sharing.js on lines 249..253

                                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 52.

                                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 (let i = 0; i < endEvents.length; i++) {
                                      // disable drag when mouse leaves this or the parent
                                      slider.parent().on(endEvents[i], endFunc)
                                      tabs.on(endEvents[i], endFunc)
                                    }
                                Severity: Minor
                                Found in game/static/game/js/game.js and 1 other location - About 30 mins to fix
                                game/static/game/js/game.js on lines 364..368

                                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 45.

                                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 (let i = 0; i < endEvents.length; i++) {
                                      // disable drag when mouse leaves this or the parent
                                      slider.parent().off(endEvents[i], endFunc)
                                      tabs.off(endEvents[i], endFunc)
                                    }
                                Severity: Minor
                                Found in game/static/game/js/game.js and 1 other location - About 30 mins to fix
                                game/static/game/js/game.js on lines 406..410

                                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 45.

                                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