plainblack/Lacuna-Web-Client

View on GitHub
app/js-yui/building/planetaryCommand.js

Summary

Maintainability
F
6 days
Test Coverage

File planetaryCommand.js has 346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

YAHOO.namespace("lacuna.buildings");

var $ = require('js/shims/jquery');

var MapActions = require('js/actions/menu/map');
Severity: Minor
Found in app/js-yui/building/planetaryCommand.js - About 4 hrs to fix

    Function _getResourcesTab has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _getResourcesTab : function() {
    
                var food_items = '',
                    foods      = Lib.ResourceTypes.food;
    
    
    Severity: Major
    Found in app/js-yui/building/planetaryCommand.js - About 2 hrs to fix

      Function _getPlanetTab has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _getPlanetTab : function() {
                  var planet = this.result.planet;
                  var details = function(type,imgclass) {
                      var Type = Lib.capitalizeFirstLetter(type);
                      var stored   = planet[type+"_stored"] || planet[type];
      Severity: Major
      Found in app/js-yui/building/planetaryCommand.js - About 2 hrs to fix

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

                PlanPopulate : function(){
                    var div = Dom.get("planDetails");
                    if(div) {
                        var divParent = div.parentNode,
                            ul = document.createElement("ul"),
        Severity: Minor
        Found in app/js-yui/building/planetaryCommand.js - About 1 hr to fix

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

                  Abandon : function() {
                      var cp = Game.GetCurrentPlanet();
                      if(confirm(['Are you sure you want to abandon ',cp.name,'?'].join(''))) {
                          require('js/actions/menu/loader').show();
                          Game.Services.Body.abandon({
          Severity: Minor
          Found in app/js-yui/building/planetaryCommand.js - About 1 hr to fix

            Function Rename has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    Rename : function() {
                        var newName = Dom.get("commandPlanetNewName").value,
                            cp = Game.GetCurrentPlanet(),
                            planetId = cp.id;
                        Game.Services.Body.rename({
            Severity: Minor
            Found in app/js-yui/building/planetaryCommand.js - About 1 hr to fix

              Function success has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                              success : function(o){
                                  YAHOO.log(o, "info", "PlanetaryCommand.abandon.success");
                                  this.rpcSuccess(o);
              
                                  delete Game.EmpireData.planets[cp.id]; // Remove the abandoned planet
              Severity: Minor
              Found in app/js-yui/building/planetaryCommand.js - About 1 hr to fix

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

                        _getPlanTab : function() {
                            this.planTab = new YAHOO.widget.Tab({ label: "Plans", content: [
                                '<ul class="plan planHeader clearafter"><li class="planQuan">Quantity</li><li class="planName">Name</li><li class="planLevel">Level</li><li class="planExtra">Extra Level</li></ul>',
                                '<div>',
                                '    <div id="planDetails">',
                Severity: Minor
                Found in app/js-yui/building/planetaryCommand.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if(tile) {
                                                  if(tile.domElement) {
                                                      var domEl = tile.domElement; // get the element
                                                      var childEl = domEl.childNodes[1]; // find the alignment child
                                                      if(childEl) {
                  Severity: Major
                  Found in app/js-yui/building/planetaryCommand.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if(Lacuna.MapStar._map.tileCache[cp.x] && Lacuna.MapStar._map.tileCache[cp.x][cp.y]) {
                                                    delete Lacuna.MapStar._map.tileCache[cp.x][cp.y]; // Remove the planet from the cache
                                                }
                    Severity: Major
                    Found in app/js-yui/building/planetaryCommand.js - About 45 mins to fix

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

                                  for(x=0; x < ores.length; x++) {
                                      ore = ores[x];
                      
                                      ore_items += [
                                          '<li><label>',
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 6 hrs to fix
                      app/js-yui/building/planetaryCommand.js on lines 153..165

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

                      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(x=0; x < foods.length; x++) {
                                      food = foods[x];
                      
                                      food_items += [
                                          '<li><label>',
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 6 hrs to fix
                      app/js-yui/building/planetaryCommand.js on lines 170..182

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

                      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(e.newValue) {
                                          if(!this.plans) {
                                              require('js/actions/menu/loader').show();
                                              this.service.view_plans({session_id:Game.GetSession(),building_id:this.building.id}, {
                                                  success : function(o){
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 6 hrs to fix
                      app/js-yui/building/missionCommand.js on lines 45..61

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

                      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

                                  ore_items += [
                                          '<li><label>Energy</label><span class="pcStored" title="', Lib.formatNumber(this.result.planet.energy_stored),'">',
                                          Lib.convertNumDisplay(this.result.planet.energy_stored),
                                          '</span> @ <span class="pcPerHour" title="',Lib.formatNumber(this.result.planet.energy_hour),'">',
                                          Lib.convertNumDisplay(this.result.planet.energy_hour),
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 3 hrs to fix
                      app/js-yui/building/planetaryCommand.js on lines 183..189

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

                      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

                                  ore_items += [
                                          '<li><label>Water</label><span class="pcStored" title="', Lib.formatNumber(this.result.planet.water_stored),'">',
                                          Lib.convertNumDisplay(this.result.planet.water_stored),
                                          '</span> @ <span class="pcPerHour" title="',Lib.formatNumber(this.result.planet.water_hour),'">',
                                          Lib.convertNumDisplay(this.result.planet.water_hour),
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 3 hrs to fix
                      app/js-yui/building/planetaryCommand.js on lines 190..196

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

                      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(Lacuna.MapStar._map.tileCache[cp.x] && Lacuna.MapStar._map.tileCache[cp.x][cp.y]) {
                                                      delete Lacuna.MapStar._map.tileCache[cp.x][cp.y]; // Remove the planet from the cache
                                                  }
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 2 hrs to fix
                      app/js-yui/mapper.js on lines 782..784

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

                      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

                                      setTimeout(function() {
                                          var Ht = Game.GetSize().h - 170;
                                          if(Ht > 300) { Ht = 300; }
                                          Dom.setStyle(divParent,"height",Ht + "px");
                                          Dom.setStyle(divParent,"overflow-y","auto");
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 3 other locations - About 2 hrs to fix
                      app/js-yui/building.js on lines 438..443
                      app/js-yui/building/blackHoleGenerator.js on lines 338..343
                      app/js-yui/building/tradeMinistry.js on lines 2064..2069

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

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

                          var Lang = YAHOO.lang,
                              Util = YAHOO.util,
                              Dom = Util.Dom,
                              Event = Util.Event,
                              Sel = Util.Selector,
                      Severity: Major
                      Found in app/js-yui/building/planetaryCommand.js and 16 other locations - About 1 hr to fix
                      app/js-yui/building.js on lines 8..15
                      app/js-yui/building/development.js on lines 6..13
                      app/js-yui/building/distributionCenter.js on lines 6..13
                      app/js-yui/building/geneticsLab.js on lines 6..13
                      app/js-yui/building/missionCommand.js on lines 6..13
                      app/js-yui/building/network19.js on lines 6..13
                      app/js-yui/building/park.js on lines 6..13
                      app/js-yui/building/shipyard.js on lines 6..13
                      app/js-yui/building/spaceStationLab.js on lines 6..13
                      app/js-yui/login.js on lines 13..20
                      app/js-yui/mapPlanet.js on lines 12..19
                      app/js-yui/mapStar.js on lines 8..15
                      app/js-yui/module/parliament.js on lines 6..13
                      app/js-yui/module/stationCommand.js on lines 6..13
                      app/js-yui/profile.js on lines 13..20
                      app/js-yui/stats.js on lines 12..19

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 74.

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

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

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

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

                      Refactorings

                      Further Reading

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

                                          failure : function(o){
                                              Dom.get("commandPlanetRenameMessage").innerHTML = o.error.message;
                                              Lib.fadeOutElm("commandPlanetRenameMessage");
                                              return true;
                                          },
                      Severity: Minor
                      Found in app/js-yui/building/planetaryCommand.js and 1 other location - About 50 mins to fix
                      app/js-yui/mapStar.js on lines 1466..1470

                      Duplicated Code

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

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

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

                      Tuning

                      This issue has a mass of 52.

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

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

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

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

                      Refactorings

                      Further Reading

                      There are no issues that match your filters.

                      Category
                      Status