plainblack/Lacuna-Web-Client

View on GitHub
app/js/game.jsx

Summary

Maintainability
F
1 wk
Test Coverage

File game.jsx has 798 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

YAHOO.namespace('lacuna');

var React               = require('react');
Severity: Major
Found in app/js/game.jsx - About 1 day to fix

    Function ProcessStatus has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                ProcessStatus : function(status) {
                    if (status) {
    
                        if (status.server) {
                            // add everything from status empire to game empire
    Severity: Major
    Found in app/js/game.jsx - About 3 hrs to fix

      Function Start has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  Start : function(query) {
                      var l = window.location;
                      Game.RPCBase = window.lacuna_rpc_base_url || l.protocol + '//' + l.host + '/';
                      Game.domain = l.hostname || 'lacunaexpanse.com';
      
      
      Severity: Major
      Found in app/js/game.jsx - About 3 hrs to fix

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

                    Tick : function() {
                        var ED = Lacuna.Game.EmpireData;
                        var SD = Lacuna.Game.ServerData;
                        var dt = (new Date()).getTime();
                        var diff = dt - Lacuna.Game.recTime;
        Severity: Major
        Found in app/js/game.jsx - About 3 hrs to fix

          Function onScroll has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      onScroll : (function() {
                          var pixelsPerLine = 10;
                          var ua = navigator.userAgent;
                          var safari5 = ua.match(/\bSafari\//) && ua.match(/\bVersion\/5/);
                          var isEventSupported = (function() {
          Severity: Major
          Found in app/js/game.jsx - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

            if (typeof YAHOO.lacuna.Game === 'undefined' || !YAHOO.lacuna.Game) {
            
                (function() {
                    var Util = YAHOO.util;
                    var Lang = YAHOO.lang;
            Severity: Critical
            Found in app/js/game.jsx - About 2 hrs to fix

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

                          WrappedService : function(method, name) {
                              var logNS = 'Game.RPC.' + name + '.failure';
                              var func = function(params, origOpts) {
                                  var retry = function() {
                                      var opts = { retry : 0 };
              Severity: Minor
              Found in app/js/game.jsx - About 1 hr to fix

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

                            InitLogin : function() {
                                if (!Lacuna.Game.LoginDialog) {
                                    Lacuna.Game.LoginDialog = new Lacuna.Login();
                                    Lacuna.Game.LoginDialog.subscribe('onLoginSuccessful', function(oArgs) {
                                        var result = oArgs.result;
                Severity: Minor
                Found in app/js/game.jsx - About 1 hr to fix

                  Function Failure has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              Failure : function(o, retry, fail) {
                                  // session expired
                                  if (o.error.code === 1006) {
                                      Game.Reset();
                                      Game.DoLogin(o.error);
                  Severity: Minor
                  Found in app/js/game.jsx - About 1 hr to fix

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

                                    var func = function(params, origOpts) {
                                        var retry = function() {
                                            var opts = { retry : 0 };
                                            YAHOO.lang.augmentObject(opts, origOpts, true);
                                            opts.retry++;
                    Severity: Minor
                    Found in app/js/game.jsx - About 1 hr to fix

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

                                  QuickDialog : function(config, afterRender, afterHide) {
                                      var container = document.createElement('div');
                                      if (config.id) {
                                          container.id = config.id;
                                          delete config.id;
                      Severity: Minor
                      Found in app/js/game.jsx - About 1 hr to fix

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

                                        var isEventSupported = (function() {
                                            var TAGNAMES = {
                                                'select' : 'input',
                                                'change' : 'input',
                                                'submit' : 'form',
                        Severity: Minor
                        Found in app/js/game.jsx - About 1 hr to fix

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

                                      QueueProcess : function(e, oArgs) {
                                          // only do anything if the queue actually has data
                                          if (Game.queue) {
                                              var toFire = {};
                                              var tickMS = oArgs[0];
                          Severity: Minor
                          Found in app/js/game.jsx - About 1 hr to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        if (status.empire.planets.hasOwnProperty(pKey)) {
                                                            var ePlanet = Lacuna.Game.EmpireData.planets[pKey];
                                                            if (!ePlanet) {
                                                                Lacuna.Game.EmpireData.planets[pKey] = {
                                                                    id              : pKey,
                            Severity: Major
                            Found in app/js/game.jsx - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if (planet.ore_stored > planet.ore_capacity) {
                                                              planet.ore_stored = planet.ore_capacity;
                                                          } else if (planet.ore_stored < 0) {
                                                              if (isNotStation) {
                                                                  planet.happiness += planet.ore_stored;
                              Severity: Major
                              Found in app/js/game.jsx - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                            if (planet.waste_stored > planet.waste_capacity) {
                                                                wasteOverage = planet.waste_stored - planet.waste_capacity;
                                                                planet.waste_stored = planet.waste_capacity;
                                                            } else if (planet.waste_stored < 0) {
                                                                if (isNotStation) {
                                Severity: Major
                                Found in app/js/game.jsx - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                              if (planet.energy_stored > planet.energy_capacity) {
                                                                  planet.energy_stored = planet.energy_capacity;
                                                              } else if (planet.energy_stored < 0) {
                                                                  if (isNotStation) {
                                                                      planet.happiness += planet.energy_stored;
                                  Severity: Major
                                  Found in app/js/game.jsx - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                                for (var id in qt) {
                                                                    if (qt.hasOwnProperty(id)) {
                                                                        var ms = qt[id] - tickMS;
                                                                        if (ms <= 0) {
                                                                            toFire[id] = type;
                                    Severity: Major
                                    Found in app/js/game.jsx - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                                  if (planet.water_stored > planet.water_capacity) {
                                                                      planet.water_stored = planet.water_capacity;
                                                                  } else if (planet.water_stored < 0) {
                                                                      if (isNotStation) {
                                                                          planet.happiness += planet.water_stored;
                                      Severity: Major
                                      Found in app/js/game.jsx - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                                    if (planet.food_stored > planet.food_capacity) {
                                                                        planet.food_stored = planet.food_capacity;
                                                                    } else if (planet.food_stored < 0) {
                                                                        if (isNotStation) {
                                                                            planet.happiness += planet.food_stored;
                                        Severity: Major
                                        Found in app/js/game.jsx - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                                      if (planet.happiness < 0 && ED.is_isolationist === '1') {
                                                                          planet.happiness = 0;
                                                                      }
                                          Severity: Major
                                          Found in app/js/game.jsx - About 45 mins to fix

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

                                                                    if (planet.water_stored < planet.water_capacity) {
                                                                        planet.water_stored += planet.water_hour * ratio;
                                            
                                                                        if (planet.water_stored > planet.water_capacity) {
                                                                            planet.water_stored = planet.water_capacity;
                                            Severity: Major
                                            Found in app/js/game.jsx and 3 other locations - About 4 hrs to fix
                                            app/js/game.jsx on lines 672..683
                                            app/js/game.jsx on lines 685..696
                                            app/js/game.jsx on lines 698..709

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

                                            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 (planet.ore_stored < planet.ore_capacity) {
                                                                        planet.ore_stored += planet.ore_hour * ratio;
                                            
                                                                        if (planet.ore_stored > planet.ore_capacity) {
                                                                            planet.ore_stored = planet.ore_capacity;
                                            Severity: Major
                                            Found in app/js/game.jsx and 3 other locations - About 4 hrs to fix
                                            app/js/game.jsx on lines 672..683
                                            app/js/game.jsx on lines 685..696
                                            app/js/game.jsx on lines 711..722

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

                                            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 (planet.energy_stored < planet.energy_capacity) {
                                                                        planet.energy_stored += planet.energy_hour * ratio;
                                            
                                                                        if (planet.energy_stored > planet.energy_capacity) {
                                                                            planet.energy_stored = planet.energy_capacity;
                                            Severity: Major
                                            Found in app/js/game.jsx and 3 other locations - About 4 hrs to fix
                                            app/js/game.jsx on lines 685..696
                                            app/js/game.jsx on lines 698..709
                                            app/js/game.jsx on lines 711..722

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

                                            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 (planet.food_stored < planet.food_capacity) {
                                                                        planet.food_stored += planet.food_hour * ratio;
                                            
                                                                        if (planet.food_stored > planet.food_capacity) {
                                                                            planet.food_stored = planet.food_capacity;
                                            Severity: Major
                                            Found in app/js/game.jsx and 3 other locations - About 4 hrs to fix
                                            app/js/game.jsx on lines 672..683
                                            app/js/game.jsx on lines 698..709
                                            app/js/game.jsx on lines 711..722

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

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

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

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

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

                                            Refactorings

                                            Further Reading

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

                                                                    for (var sKey in status.empire.stations) {
                                                                        Lacuna.Game.EmpireData.stationsByName[status.empire.stations[sKey]] = sKey;
                                                                    }
                                            Severity: Major
                                            Found in app/js/game.jsx and 1 other location - About 1 hr to fix
                                            app/js/game.jsx on lines 422..424

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

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

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

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

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

                                            Refactorings

                                            Further Reading

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

                                                                    for (var cKey in status.empire.colonies) {
                                                                        Lacuna.Game.EmpireData.coloniesByName[status.empire.colonies[cKey]] = cKey;
                                                                    }
                                            Severity: Major
                                            Found in app/js/game.jsx and 1 other location - About 1 hr to fix
                                            app/js/game.jsx on lines 425..427

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

                                            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