ocadotechnology/rapid-router

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

Summary

Maintainability
F
2 wks
Test Coverage

Function Drawing has a Cognitive Complexity of 205 (exceeds 5 allowed). Consider refactoring.
Open

ocargo.Drawing = function (startingPosition) {
  /*************/
  /* Constants */
  /*************/

Severity: Minor
Found in game/static/game/js/drawing.js - About 4 days 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 Drawing has 803 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ocargo.Drawing = function (startingPosition) {
  /*************/
  /* Constants */
  /*************/

Severity: Major
Found in game/static/game/js/drawing.js - About 4 days to fix

    File drawing.js has 1018 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict'
    
    var ocargo = ocargo || {}
    
    let GRID_WIDTH = 10
    Severity: Major
    Found in game/static/game/js/drawing.js - About 2 days to fix

      Function renderRoad has 183 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        this.renderRoad = function (nodes) {
          for (let i = 0; i < roadImages.length; i++) {
            let image = roadImages[i]
            if (image) {
              image.remove()
      Severity: Major
      Found in game/static/game/js/drawing.js - About 7 hrs to fix

        Function renderDestinations has 113 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          this.renderDestinations = function (destinations) {
            for (let i = 0; i < destinations.length; i++) {
              let destination = destinations[i].node
              let variation = getDestinationPosition(destination)
        
        
        Severity: Major
        Found in game/static/game/js/drawing.js - About 4 hrs to fix

          Function startPopup has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          ocargo.Drawing.startPopup = function (
            title,
            subtitle,
            message,
            mascot,
          Severity: Minor
          Found in game/static/game/js/drawing.js - About 3 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          ocargo.Drawing.startPopup = function (
            title,
            subtitle,
            message,
            mascot,
          Severity: Major
          Found in game/static/game/js/drawing.js - About 3 hrs to fix

            Function getDestinationPosition has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function getDestinationPosition (destination) {
                  let roadLetters = []
            
                  //might be best to just use the coordinates rather than get road letters and then convert back to directions
                  if (destination.connectedNodes.length === 1) {
            Severity: Major
            Found in game/static/game/js/drawing.js - About 3 hrs to fix

              Function determineCowOrientation has 75 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                this.determineCowOrientation = function (coordinate, node) {
                  let x = coordinate.x
                  let y = coordinate.y
              
                  let xOffset = 0
              Severity: Major
              Found in game/static/game/js/drawing.js - About 3 hrs to fix

                Function drawTJunction has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function drawTJunction (node, path) {
                      let node1 = node.connectedNodes[0]
                      let node2 = node.connectedNodes[1]
                      let node3 = node.connectedNodes[2]
                
                
                Severity: Major
                Found in game/static/game/js/drawing.js - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                        } else if (
                          (letters12 === 'V' && (letters13 === 'UR' || letters13 === 'DR')) ||
                          (letters12 === 'UR' && (letters13 === 'DR' || letters13 === 'V')) ||
                          (letters12 === 'DR' && (letters13 === 'UR' || letters13 === 'V'))
                        ) {
                  Severity: Critical
                  Found in game/static/game/js/drawing.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                          } else if (
                            (letters12 === 'H' && (letters13 === 'UL' || letters13 === 'UR')) ||
                            (letters12 === 'UL' && (letters13 === 'UR' || letters13 === 'H')) ||
                            (letters12 === 'UR' && (letters13 === 'UL' || letters13 === 'H'))
                          ) {
                    Severity: Critical
                    Found in game/static/game/js/drawing.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                            } else if (
                              (letters12 === 'H' && (letters13 === 'DL' || letters13 === 'DR')) ||
                              (letters12 === 'DL' && (letters13 === 'DR' || letters13 === 'H')) ||
                              (letters12 === 'DR' && (letters13 === 'DL' || letters13 === 'H'))
                            ) {
                      Severity: Critical
                      Found in game/static/game/js/drawing.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                              if (
                                (letters12 === 'V' && (letters13 === 'UL' || letters13 === 'DL')) ||
                                (letters12 === 'UL' && (letters13 === 'DL' || letters13 === 'V')) ||
                                (letters12 === 'DL' && (letters13 === 'UL' || letters13 === 'V'))
                              ) {
                        Severity: Critical
                        Found in game/static/game/js/drawing.js - About 1 hr to fix

                          Function drawDeadEndRoad has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function drawDeadEndRoad (node, path) {
                                let previousNode = node.connectedNodes[0]
                          
                                let nextNode = {}
                                nextNode.coordinate = new ocargo.Coordinate(
                          Severity: Minor
                          Found in game/static/game/js/drawing.js - About 1 hr to fix

                            Function drawSingleRoadSegment has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function drawSingleRoadSegment (previousNode, node, nextNode, path) {
                                  let roadLetters = getRoadLetters(
                                    previousNode.coordinate,
                                    node.coordinate,
                                    nextNode.coordinate
                            Severity: Minor
                            Found in game/static/game/js/drawing.js - About 1 hr to fix

                              Function renderTrafficLights has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                this.renderTrafficLights = function (trafficLights) {
                                  for (let i = 0; i < trafficLights.length; i++) {
                                    let trafficLight = trafficLights[i]
                                    let sourceCoordinate = trafficLight.sourceNode.coordinate
                                    let controlledCoordinate = trafficLight.controlledNode.coordinate
                              Severity: Minor
                              Found in game/static/game/js/drawing.js - About 1 hr to fix

                                Function getRoadLetters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  function getRoadLetters (previous, node1, node2) {
                                    previous = ocargo.Drawing.translate(previous)
                                    node1 = ocargo.Drawing.translate(node1)
                                    node2 = ocargo.Drawing.translate(node2)
                                
                                
                                Severity: Minor
                                Found in game/static/game/js/drawing.js - About 1 hr to fix

                                  Function preloadRoadTiles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    this.preloadRoadTiles = function () {
                                      let tiles = ['dead_end', 'crossroads', 'straight', 't_junction', 'turn']
                                      let tileImages = []
                                      let path = ocargo.Drawing.raphaelImageDir + 'road_tiles/'
                                  
                                  
                                  Severity: Minor
                                  Found in game/static/game/js/drawing.js - About 1 hr to fix

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

                                      title,
                                      subtitle,
                                      message,
                                      yesFunction,
                                      noFunction,
                                    Severity: Minor
                                    Found in game/static/game/js/drawing.js - About 45 mins to fix

                                      Function renderCow has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                        this.renderCow = function (id, coordinate, node, animationLength, type) {
                                      Severity: Minor
                                      Found in game/static/game/js/drawing.js - About 35 mins to fix

                                        Function startPopup has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                          title,
                                          subtitle,
                                          message,
                                          mascot,
                                          buttons
                                        Severity: Minor
                                        Found in game/static/game/js/drawing.js - About 35 mins to fix

                                          Function createImage has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                            this.createImage = function (url, x, y, width, height) {
                                          Severity: Minor
                                          Found in game/static/game/js/drawing.js - About 35 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return nextPointFurther(node1, node2) ? 'UR' : 'UL'
                                            Severity: Major
                                            Found in game/static/game/js/drawing.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return nextPointFurther(node1, node2) ? 'DR' : 'DL'
                                              Severity: Major
                                              Found in game/static/game/js/drawing.js - About 30 mins to fix

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

                                                      nextNode.coordinate = new ocargo.Coordinate(
                                                        node.coordinate.x + (node.coordinate.x - previousNode.coordinate.x),
                                                        node.coordinate.y + (node.coordinate.y - previousNode.coordinate.y)
                                                      )
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 2 other locations - About 2 hrs to fix
                                                game/static/game/js/drawing.js on lines 335..340
                                                game/static/game/js/drawing.js on lines 758..761

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

                                                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

                                                      nextNode.coordinate = new ocargo.Coordinate(
                                                        node.coordinate.x + (node.coordinate.x - previousNode.coordinate.x),
                                                        node.coordinate.y + (node.coordinate.y - previousNode.coordinate.y)
                                                      )
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 2 other locations - About 2 hrs to fix
                                                game/static/game/js/drawing.js on lines 335..340
                                                game/static/game/js/drawing.js on lines 495..498

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

                                                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

                                                        nextNode.coordinate = new ocargo.Coordinate(
                                                          destination.coordinate.x +
                                                            (destination.coordinate.x - previousNode.coordinate.x),
                                                          destination.coordinate.y +
                                                            (destination.coordinate.y - previousNode.coordinate.y)
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 2 other locations - About 2 hrs to fix
                                                game/static/game/js/drawing.js on lines 495..498
                                                game/static/game/js/drawing.js on lines 758..761

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

                                                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

                                                    if (shouldZoomOut) {
                                                      let newX = currentStartX - zoom
                                                      let newY = currentStartY - zoom
                                                
                                                      currentHeight = currentHeight + zoom * 2
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 1 other location - About 2 hrs to fix
                                                game/static/game/js/drawing.js on lines 97..108

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

                                                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

                                                    else {
                                                      let newX = currentStartX + zoom
                                                      let newY = currentStartY + zoom
                                                
                                                      currentHeight = currentHeight - zoom * 2
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 1 other location - About 2 hrs to fix
                                                game/static/game/js/drawing.js on lines 85..96

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

                                                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

                                                      } else if (
                                                        (letters12 === 'H' && (letters13 === 'DL' || letters13 === 'DR')) ||
                                                        (letters12 === 'DL' && (letters13 === 'DR' || letters13 === 'H')) ||
                                                        (letters12 === 'DR' && (letters13 === 'DL' || letters13 === 'H'))
                                                      ) {
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 3 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 604..628
                                                game/static/game/js/drawing.js on lines 610..628
                                                game/static/game/js/drawing.js on lines 616..628

                                                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 4 locations. Consider refactoring.
                                                Open

                                                      } else if (
                                                        (letters12 === 'H' && (letters13 === 'UL' || letters13 === 'UR')) ||
                                                        (letters12 === 'UL' && (letters13 === 'UR' || letters13 === 'H')) ||
                                                        (letters12 === 'UR' && (letters13 === 'UL' || letters13 === 'H'))
                                                      ) {
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 3 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 604..628
                                                game/static/game/js/drawing.js on lines 616..628
                                                game/static/game/js/drawing.js on lines 622..628

                                                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 4 locations. Consider refactoring.
                                                Open

                                                      if (
                                                        (letters12 === 'V' && (letters13 === 'UL' || letters13 === 'DL')) ||
                                                        (letters12 === 'UL' && (letters13 === 'DL' || letters13 === 'V')) ||
                                                        (letters12 === 'DL' && (letters13 === 'UL' || letters13 === 'V'))
                                                      ) {
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 3 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 610..628
                                                game/static/game/js/drawing.js on lines 616..628
                                                game/static/game/js/drawing.js on lines 622..628

                                                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 4 locations. Consider refactoring.
                                                Open

                                                      } else if (
                                                        (letters12 === 'V' && (letters13 === 'UR' || letters13 === 'DR')) ||
                                                        (letters12 === 'UR' && (letters13 === 'DR' || letters13 === 'V')) ||
                                                        (letters12 === 'DR' && (letters13 === 'UR' || letters13 === 'V'))
                                                      ) {
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 3 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 604..628
                                                game/static/game/js/drawing.js on lines 610..628
                                                game/static/game/js/drawing.js on lines 622..628

                                                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

                                                    } else {
                                                      lightImages[lightID][0].animate(
                                                        { opacity: 0 },
                                                        animationLength / 2,
                                                        'linear'
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 1 other location - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 932..939

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

                                                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

                                                    if (endState === ocargo.TrafficLight.GREEN) {
                                                      lightImages[lightID][0].animate(
                                                        { opacity: 1 },
                                                        animationLength / 2,
                                                        'linear'
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 1 other location - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 939..946

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

                                                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 6 locations. Consider refactoring.
                                                Open

                                                      } else if (roadLetters === 'UR') {
                                                        road.rotate(
                                                          180,
                                                          flipped.x * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING,
                                                          flipped.y * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 5 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 517..535
                                                game/static/game/js/drawing.js on lines 523..535
                                                game/static/game/js/drawing.js on lines 529..535
                                                game/static/game/js/drawing.js on lines 562..580
                                                game/static/game/js/drawing.js on lines 574..580

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

                                                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 6 locations. Consider refactoring.
                                                Open

                                                      } else if (roadLetters === 'DR') {
                                                        road.rotate(
                                                          270,
                                                          flipped.x * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING,
                                                          flipped.y * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 5 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 517..535
                                                game/static/game/js/drawing.js on lines 523..535
                                                game/static/game/js/drawing.js on lines 529..535
                                                game/static/game/js/drawing.js on lines 562..580
                                                game/static/game/js/drawing.js on lines 568..580

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

                                                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 6 locations. Consider refactoring.
                                                Open

                                                      } else if (roadLetters === 'H' && prevFlipped.x > flipped.x) {
                                                        road.rotate(
                                                          270,
                                                          flipped.x * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING,
                                                          flipped.y * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 5 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 517..535
                                                game/static/game/js/drawing.js on lines 529..535
                                                game/static/game/js/drawing.js on lines 562..580
                                                game/static/game/js/drawing.js on lines 568..580
                                                game/static/game/js/drawing.js on lines 574..580

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

                                                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 6 locations. Consider refactoring.
                                                Open

                                                      } else if (roadLetters === 'UL') {
                                                        road.rotate(
                                                          90,
                                                          flipped.x * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING,
                                                          flipped.y * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 5 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 517..535
                                                game/static/game/js/drawing.js on lines 523..535
                                                game/static/game/js/drawing.js on lines 529..535
                                                game/static/game/js/drawing.js on lines 568..580
                                                game/static/game/js/drawing.js on lines 574..580

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

                                                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 6 locations. Consider refactoring.
                                                Open

                                                      } else if (roadLetters === 'V' && prevFlipped.y < flipped.y) {
                                                        road.rotate(
                                                          180,
                                                          flipped.x * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING,
                                                          flipped.y * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 5 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 517..535
                                                game/static/game/js/drawing.js on lines 523..535
                                                game/static/game/js/drawing.js on lines 562..580
                                                game/static/game/js/drawing.js on lines 568..580
                                                game/static/game/js/drawing.js on lines 574..580

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

                                                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 6 locations. Consider refactoring.
                                                Open

                                                      if (roadLetters === 'H' && prevFlipped.x < flipped.x) {
                                                        road.rotate(
                                                          90,
                                                          flipped.x * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING,
                                                          flipped.y * GRID_SPACE_SIZE + GRID_SPACE_SIZE / 2 + PAPER_PADDING
                                                Severity: Major
                                                Found in game/static/game/js/drawing.js and 5 other locations - About 1 hr to fix
                                                game/static/game/js/drawing.js on lines 523..535
                                                game/static/game/js/drawing.js on lines 529..535
                                                game/static/game/js/drawing.js on lines 562..580
                                                game/static/game/js/drawing.js on lines 568..580
                                                game/static/game/js/drawing.js on lines 574..580

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

                                                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 (i = 0; i < coins.whole; i++) {
                                                    html +=
                                                      "<img src='" +
                                                      ocargo.Drawing.imageDir +
                                                      "coins/coin_gold.svg' width='50'>"
                                                Severity: Minor
                                                Found in game/static/game/js/drawing.js and 1 other location - About 40 mins to fix
                                                game/static/game/js/drawing.js on lines 1206..1211

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

                                                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 (i = 0; i < coins.zero; i++) {
                                                    html +=
                                                      "<img src='" +
                                                      ocargo.Drawing.imageDir +
                                                      "coins/coin_empty_dots.svg' width='50'>"
                                                Severity: Minor
                                                Found in game/static/game/js/drawing.js and 1 other location - About 40 mins to fix
                                                game/static/game/js/drawing.js on lines 1194..1199

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

                                                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

                                                      let road = paper.image(
                                                        path + 't_junction.svg',
                                                        flipped.x * GRID_SPACE_SIZE + PAPER_PADDING,
                                                        flipped.y * GRID_SPACE_SIZE + PAPER_PADDING,
                                                        GRID_SPACE_SIZE,
                                                Severity: Minor
                                                Found in game/static/game/js/drawing.js and 1 other location - About 35 mins to fix
                                                game/static/game/js/drawing.js on lines 509..515

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

                                                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

                                                      let road = paper.image(
                                                        path + 'dead_end.svg',
                                                        flipped.x * GRID_SPACE_SIZE + PAPER_PADDING,
                                                        flipped.y * GRID_SPACE_SIZE + PAPER_PADDING,
                                                        GRID_SPACE_SIZE,
                                                Severity: Minor
                                                Found in game/static/game/js/drawing.js and 1 other location - About 35 mins to fix
                                                game/static/game/js/drawing.js on lines 630..636

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

                                                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

                                                  function calculateInitialRotation (previousNode, startNode) {
                                                    let nodeAngleRadians = ocargo.calculateNodeAngle(previousNode, startNode)
                                                    let nodeAngleDegrees = nodeAngleRadians * (180 / Math.PI)
                                                    return -nodeAngleDegrees // Calculation is counterclockwise, transformations are clockwise
                                                  }
                                                Severity: Minor
                                                Found in game/static/game/js/drawing.js and 1 other location - About 35 mins to fix
                                                game/static/game/js/character.js on lines 123..127

                                                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

                                                    let transformation = ocargo.Drawing.rotationTransformationAroundCentreOfGridSpace(
                                                      rotation,
                                                      position.currentNode.coordinate.x,
                                                      position.currentNode.coordinate.y
                                                    )
                                                Severity: Minor
                                                Found in game/static/game/js/drawing.js and 1 other location - About 30 mins to fix
                                                game/static/game/js/character.js on lines 101..104

                                                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