engagementgamelab/CivicSeed

View on GitHub
client/code/game/game.main.js

Summary

Maintainability
D
2 days
Test Coverage

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

'use strict'
/* global ss, Davis, JT, $, $CONTAINER, apprise */

// PRIVATE GAME VARS
var _stepNumber = 0
Severity: Minor
Found in client/code/game/game.main.js - About 7 hrs to fix

    exports has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    var $game = module.exports = {
    
      // GLOBAL GAME CONSTANTS
      VIEWPORT_WIDTH: 30,
      VIEWPORT_HEIGHT: 15,
    Severity: Minor
    Found in client/code/game/game.main.js - About 2 hrs to fix

      Function updateProgressOverlay has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        updateProgressOverlay: function () {
          var playerLevel = $game.$player.getLevel()
          var tilesColored = $game.$player.getTilesColored()
          var resourcesDiscovered = $game.$player.getResourcesDiscovered()
          var totalResources = $game.$resources.getTotalResourceCount()
      Severity: Minor
      Found in client/code/game/game.main.js - About 1 hr to fix

        Function init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          init: function (callback) {
            console.log('Initializing all modules')
        
            // Instantiating code
            this.flags = require('/game.flags')
        Severity: Minor
        Found in client/code/game/game.main.js - About 1 hr to fix

          Function startGame has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            startGame: function (ingame) {
              if ($game.bossModeUnlocked && $game.$player.currentLevel > 3) {
                $game.$boss.init()
              }
          
          
          Severity: Minor
          Found in client/code/game/game.main.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 startGame has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            startGame: function (ingame) {
              if ($game.bossModeUnlocked && $game.$player.currentLevel > 3) {
                $game.$boss.init()
              }
          
          
          Severity: Minor
          Found in client/code/game/game.main.js - About 1 hr to fix

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

              beginTransition: function () {
                // Verify that the player is at the edge of a screen
                // Refuse transition if player is not at a transitional edge
                // This catches bugs
                var position = $game.$player.getLocalPosition()
            Severity: Minor
            Found in client/code/game/game.main.js - About 1 hr to fix

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

                enterGame: function (callback) {
                  // Check if they are ACTUALLY playing
                  ss.rpc('shared.account.checkGameSession', function (response) {
                    // YOU KNOW, THIS COULD ALL HAPPEN ELSEWHERE?
                    if (!$game.instantiated) {
              Severity: Minor
              Found in client/code/game/game.main.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 beginTransition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                beginTransition: function () {
                  // Verify that the player is at the edge of a screen
                  // Refuse transition if player is not at a transitional edge
                  // This catches bugs
                  var position = $game.$player.getLocalPosition()
              Severity: Minor
              Found in client/code/game/game.main.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

                  if (!(position.x === 0 ||
                      position.x === $game.VIEWPORT_WIDTH - 1 ||
                      position.y === 0 ||
                      position.y === $game.VIEWPORT_HEIGHT - 1) &&
              Severity: Major
              Found in client/code/game/game.main.js and 1 other location - About 1 hr to fix
              client/code/game/game.player.js on lines 215..218

              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

                      $game.minimap.addPlayer($game.$player.id, $game.$player.getPosition(), $game.$player.getCSSColor())
              Severity: Minor
              Found in client/code/game/game.main.js and 1 other location - About 40 mins to fix
              client/code/game/game.skins.js on lines 216..216

              Duplicated Code

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

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

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

              Tuning

              This issue has a mass of 49.

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

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

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

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

              Refactorings

              Further Reading

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

                log: function (message) {
                  $game.statusUpdate({
                    message: message,
                    input: 'status',
                    screen: false,
              Severity: Minor
              Found in client/code/game/game.main.js and 2 other locations - About 30 mins to fix
              client/code/game/game.main.js on lines 342..349
              client/code/game/game.main.js on lines 362..369

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

                alert: function (message) {
                  $game.statusUpdate({
                    message: message,
                    input: 'status',
                    screen: true,
              Severity: Minor
              Found in client/code/game/game.main.js and 2 other locations - About 30 mins to fix
              client/code/game/game.main.js on lines 352..359
              client/code/game/game.main.js on lines 362..369

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

                broadcast: function (message) {
                  $game.statusUpdate({
                    message: message,
                    input: 'status',
                    screen: true,
              Severity: Minor
              Found in client/code/game/game.main.js and 2 other locations - About 30 mins to fix
              client/code/game/game.main.js on lines 342..349
              client/code/game/game.main.js on lines 352..359

              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