engagementgamelab/CivicSeed

View on GitHub

Showing 258 of 421 total issues

Function checkGameSession has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    checkGameSession: function () {
      dbHelpers.checkGameActive(req.session.game.instanceName, function (active) {
        if (active) {
          UserModel.findById(req.session.userId, function (error, user) {
            if (error || !user) {
Severity: Major
Found in server/rpc/shared/account.js - About 2 hrs to fix

    Function dropSeed has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        dropSeed: function (bombed, info) {
          var minX = info.x1
          var maxX = info.x2
          var minY = info.y1
          var maxY = info.y2
    Severity: Major
    Found in server/rpc/game/player.js - About 2 hrs to fix

      Function _addButton has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function _addButton (button, section, callback) {
            var buttons = overlay.querySelector('.buttons')
            var back = buttons.querySelector('.back-button')
            var clear = buttons.querySelector('.clear-button')
            var next = buttons.querySelector('.next-button')
      Severity: Major
      Found in client/code/game/game.botanist.js - About 2 hrs to fix

        Function _move has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function _move () {
          /** IMPORTANT note: x and y are really flipped!!! **/ // is this true?
        
          // First, check what step of animation we are on.
          // After one animation cycle, reset steps and moves
        Severity: Major
        Found in client/code/game/game.player.js - About 2 hrs to fix

          Function renderMouse has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            renderMouse: function (mouse) {
              var mX = mouse.cX * $game.TILE_SIZE
              var mY = mouse.cY * $game.TILE_SIZE
              var state = $game.$map.getTileState({ x: mouse.cX, y: mouse.cY })
          
          
          Severity: Minor
          Found in client/code/game/game.render.js - About 2 hrs to fix

            Function loadTilesheets has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              loadTilesheets: function (num) {
                var path = CivicSeed.CLOUD_PATH + '/img/game/'
                var ext = '.png'
            
                // load the images recursively until done
            Severity: Minor
            Found in client/code/game/game.render.js - About 2 hrs to fix

              Function updateInformation has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  updateInformation: function (info) {
                    npcModel
                      .where('id').equals(info.id)
                      .find(function (err, result) {
                        if (err) {
              Severity: Minor
              Found in server/rpc/admin/npcs.js - About 1 hr to fix

                Function loadTiles has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  loadTiles: function (req, res, ss) {
                    var tileData = require(rootDir + '/data/tiles.json')
                
                    // Set up tile data object
                    var data = tileData.layers // This is an array of unnamed objects, we want to name them
                Severity: Minor
                Found in server/rpc/admin/startup.js - About 1 hr to fix

                  Function set has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      set: function(key, val, options) {
                        var attr, attrs, unset, changes, silent, changing, prev, current;
                        if (key == null) return this;
                  
                        // Handle both `"key", value` and `{key: value}` -style arguments.
                  Severity: Minor
                  Found in client/code/system/backbone.js - About 1 hr to fix

                    Function place has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function place (data) {
                        var bubbleEl = document.getElementById('chat-' + data.id)
                        var pointerEl = document.getElementById('chat-pointer-' + data.id)
                        var sz = bubbleEl.offsetWidth
                        var half = sz / 2
                    Severity: Minor
                    Found in client/code/game/game.chat.js - About 1 hr to fix

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

                      module.exports = (function () {
                        var _minimap = {}
                        var _minimapPlayerContext = null
                        var _minimapRadarContext = null
                        var _utils
                      Severity: Minor
                      Found in client/code/game/game.minimap.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 actions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                      exports.actions = function (req, res, ss) {
                        req.use('session')
                      
                        var UserModel = ss.service.db.model('User')
                        var GameModel = ss.service.db.model('Game')
                      Severity: Minor
                      Found in server/rpc/shared/account.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 init has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        init: function (callback) {
                          // get the players info from the db, alerts other users of presence
                          ss.rpc('game.player.init', function (playerInfo) {
                            // time in seconds since 1970 or whatever
                            _startTime = new Date().getTime() / 1000
                      Severity: Minor
                      Found in client/code/game/game.player.js - About 1 hr to fix

                        Function loadQuestion has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          loadQuestion: function (resource) {
                            var overlay = document.getElementById('resource-area')
                            var el = overlay.querySelector('.resource-question')
                            var form = el.querySelector('form')
                            var formHTML = ''
                        Severity: Minor
                        Found in client/code/game/game.resources.js - About 1 hr to fix

                          Function getTiles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            getTiles: function (data, callback) {
                              $map.dataLoaded = false
                              var x1 = data.x
                              var y1 = data.y
                              var x2 = data.x + data.numX
                          Severity: Minor
                          Found in client/code/game/game.map.js - About 1 hr to fix

                            Function exports has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports = (function () {
                              var logCounter = new Counter()
                            
                              return {
                            
                            
                            Severity: Minor
                            Found in client/code/game/game.log.js - About 1 hr to fix

                              Function cheat has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                function cheat (input) {
                                  switch (input.toLowerCase()) {
                                    case 'beam me up scotty':
                                    case 'beam me up, Scotty!':   // Legacy cheat with punctuation
                                      cheatLog('Teleporting to botanist.')
                              Severity: Minor
                              Found in client/code/game/game.input.js - About 1 hr to fix

                                Function trigger has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  function trigger (input) {
                                    switch (input) {
                                      case 'FOREST':
                                        if ($game.flags.check('teleport-forest')) {
                                          outfitLog('Teleporting to ' + $game.world.northwest.name + '!')
                                Severity: Minor
                                Found in client/code/game/game.input.js - About 1 hr to fix

                                  Function resetDefaultData has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    resetDefaultData: function (model, callback) {
                                      var collectionName = model.collection.collection.collectionName
                                  
                                      winston.info('CS: '.blue + 'Resetting default data for collection: '.magenta + collectionName.yellow.underline + ' ...'.magenta)
                                  
                                  
                                  Severity: Minor
                                  Found in server/utils/database-actions.js - About 1 hr to fix

                                    Function Player has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function Player (player) {
                                      this.name = player.firstName
                                      this.id = player._id
                                      this.isMoving = false
                                      this.currentStep = 0
                                    Severity: Minor
                                    Found in client/code/game/game.others.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language