plainblack/Lacuna-Web-Client

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

Summary

Maintainability
F
1 wk
Test Coverage

File miningMinistry.js has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

YAHOO.namespace("lacuna.buildings");

if (typeof YAHOO.lacuna.buildings.MiningMinistry == "undefined" || !YAHOO.lacuna.buildings.MiningMinistry) {
    
(function(){
Severity: Minor
Found in app/js-yui/building/miningMinistry.js - About 4 hrs to fix

    Function MiningMinistryPlatforms has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            MiningMinistryPlatforms : function() {
                var platforms = this.platforms.platforms,
                    details = Dom.get("platformDetails");
                    
                if(details) {
    Severity: Major
    Found in app/js-yui/building/miningMinistry.js - About 3 hrs to fix

      Function MiningMinistryShipsPopulate has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              MiningMinistryShipsPopulate : function() {
                  var ships = this.ships,
                      details = Dom.get("shipsDetails");
                  
                  if(details) {
      Severity: Major
      Found in app/js-yui/building/miningMinistry.js - About 2 hrs to fix

        Avoid deeply nested control flow statements.
        Open

                                if(totals[ore_i] > 0) {
                                    outOre.push('<li><label>' + ore.replace(/^\w/, function(c){ return c.toUpperCase() }) + ':</label> ');
                                    outOre.push(totals[ore_i]);
                                    outOre.push('</li>');
                                }
        Severity: Major
        Found in app/js-yui/building/miningMinistry.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for (var ore_i in ores) {
                                      var ore = ores[ore_i];
                                      if(obj[ore + '_hour'] > 0) {
                                          outOre.push('<li><label>' + ore.replace(/^\w/, function(c){ return c.toUpperCase() }) + ':</label> ');
                                          outOre.push(obj[ore+'_hour']);
          Severity: Major
          Found in app/js-yui/building/miningMinistry.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if(total > 0) {
                                        outOre.splice(1, 0, '<li><label>Total:</label> ');
                                        outOre.splice(2, 0, parseInt(total));
                                        outOre.splice(3, 0, '</li>');
                                        grand_total += total;
            Severity: Major
            Found in app/js-yui/building/miningMinistry.js - About 45 mins to fix

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

                          if(confirm(["Are you sure you want to Abandon the mining platform at  ",this.Platform.asteroid.name,"?"].join(''))) {
                              require('js/actions/menu/loader').show();
                              
                              this.Self.service.abandon_platform({
                                  session_id:Game.GetSession(),
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 1 day to fix
              app/js-yui/building/archaeology.js on lines 406..429

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

              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

                      MiningMinistryShipsAdd : function() {
                          require('js/actions/menu/loader').show();
                              
                          this.Self.service.add_cargo_ship_to_fleet({
                              session_id:Game.GetSession(),
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 6 hrs to fix
              app/js-yui/building/miningMinistry.js on lines 370..387

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

              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

                      MiningMinistryShipsRemove : function() {
                          require('js/actions/menu/loader').show();
                          
                          this.Self.service.remove_cargo_ship_from_fleet({
                              session_id:Game.GetSession(),
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 6 hrs to fix
              app/js-yui/building/miningMinistry.js on lines 352..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 167.

              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

                      AbandonAllPlatforms : function(e) {
                          if(confirm("Are you sure you want to abandon all platforms controlled by this Mining Ministry?")) {
                              require('js/actions/menu/loader').show();
                              this.service.mass_abandon_platform({
                                      session_id:Game.GetSession(),
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 2 other locations - About 6 hrs to fix
              app/js-yui/building/archaeology.js on lines 662..681
              app/js-yui/building/observatory.js on lines 187..206

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

              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

                      MiningMinistryShipsView : function() {
                          require('js/actions/menu/loader').show();
                          this.service.view_ships({session_id:Game.GetSession(),building_id:this.building.id}, {
                              success : function(o){
                                  YAHOO.log(o, "info", "MiningMinistry.MiningMinistryShipsView.success");
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 5 hrs to fix
              app/js-yui/building/tradeMinistry.js on lines 2447..2460

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

              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

                      _getShipsTab : function() {
                          this.shipsTab = new YAHOO.widget.Tab({ label: "Ships", content: [
                              '<div class="shipsContainer">',
                              '    <ul class="shipHeader shipInfo clearafter">',
                              '        <li class="shipName">Name</li>',
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 2 hrs to fix
              app/js-yui/building/spacePort.js on lines 86..102

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

              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 if(capacity == 0) {
                              output.push('You are producing an insignificant amount of ore. Add more platforms or upgrade your Mining Ministry.');
                          }
                          else if(capacity > 100) {
                              output.push('You are producing more than your ships can handle. Add more ship to bring the value closer to 100.');
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 2 hrs to fix
              app/js-yui/building/tradeMinistry.js on lines 2073..2084

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

              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

                      _getPlatformTab : function() {
                          this.platformTab = new YAHOO.widget.Tab({ label: "Platforms", content: [
                              '<div id="platformShippingInfo"></div>',
                              '<div class="platformContainer">',
                              '    <div id="platformDetails">',
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 2 hrs to fix
              app/js-yui/building/archaeology.js on lines 267..278

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

              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

                      _getAbandonAllPlatformsTab : function() {
                          this.probesTab = new YAHOO.widget.Tab({ label: "Abandon All Platforms", content: [
                                  '<div>',
                                  '    <button type="button" id="miningMinistryBigRedButton">Abandon All Platforms!</button>',
                                  '</div>'
              Severity: Major
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 2 hrs to fix
              app/js-yui/building/observatory.js on lines 47..57

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

              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

                                      nLi.innerHTML = ['<img src="',Lib.AssetUrl,'star_system/',obj.asteroid.image,'.png" />',obj.asteroid.name].join('');
              Severity: Minor
              Found in app/js-yui/building/miningMinistry.js and 1 other location - About 35 mins to fix
              app/js-yui/building/archaeology.js on lines 349..349

              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

              There are no issues that match your filters.

              Category
              Status