plainblack/Lacuna-Web-Client

View on GitHub

Showing 509 of 1,320 total issues

Consider simplifying this complex logical expression.
Open

if (typeof YAHOO.lacuna.buildings.Building == "undefined" || !YAHOO.lacuna.buildings.Building) {

(function(){
    var Lang = YAHOO.lang,
        Util = YAHOO.util,
Severity: Major
Found in app/js-yui/building.js - About 1 hr to fix

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

    var sendRequest = function(url, data, options, retry) {
        console.log('Calling', options.module + '/' + options.method, options.params);
    
        $.ajax({
            data     : data,
    Severity: Minor
    Found in app/js/server.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

    Avoid deeply nested control flow statements.
    Open

                            if(tile) {
                                if(tile.blank) {
                                    tile.refresh();
                                }
                                tile.appendToDom();
    Severity: Major
    Found in app/js-yui/mapper.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  for(var x=0; x < resource.length; x++) {
                                      nOpt = opt.cloneNode(false);
                                      nOpt.value = resource[x];
                                      nOpt.innerHTML = resource[x].titleCaps();
                                      optGroup.appendChild(nOpt);
      Severity: Major
      Found in app/js-yui/building/transporter.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                else if(resource) {
                                    nOpt = opt.cloneNode(false);
                                    nOpt.value = r;
                                    nOpt.innerHTML = r.titleCaps();
                                    elm.appendChild(nOpt);
        Severity: Major
        Found in app/js-yui/building/transporter.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if(Lang.isArray(resource)) {
                                      for(x=0; x < resource.length; x++) {
                                          name = resource[x];
                                          if(this.resources[name]) {
                                              nLi = li.cloneNode(false);
          Severity: Major
          Found in app/js-yui/building/transporter.js - About 45 mins to fix

            Function PlanetTile has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                Mapper.PlanetTile = function(x, y, z, ox, oy, layer) {
            Severity: Minor
            Found in app/js-yui/mapper.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if(doSub) {
                                          tile.unsubscribeAll(); //so we don't get multiple subs on the same tile
                                          tile.subscribe("onReload", this.onReloadTile, this, true);
                                      }
              Severity: Major
              Found in app/js-yui/mapper.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if(star.bodies.hasOwnProperty(bKey)){
                                            var body = star.bodies[bKey];
                                            body.isPlanet = true;
                                            if(!this.tileCache[body.x]) {
                                                this.tileCache[body.x] = {};
                Severity: Major
                Found in app/js-yui/mapper.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (obj.id > 0) {
                                nLi = li.cloneNode(false);
                                Dom.addClass(nLi,"excavatorAbandon");
                                var bbtn = document.createElement("button");
                                bbtn.setAttribute("type", "button");
                  Severity: Major
                  Found in app/js-yui/building/archaeology.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    if(Dom.getStyle("tradeAddGlyphName", "display") == "none") {
                                                        Dom.setStyle("tradeAddGlyphName", "display", "block");
                                                        this.getGlyphs();
                                                    }
                                                    else {
                    Severity: Major
                    Found in app/js-yui/building/transporter.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if(Lang.isArray(resource)) {
                                                  for(x=0; x < resource.length; x++) {
                                                      name = resource[x];
                                                      if(this.resources[name]) {
                                                          nLi = li.cloneNode(false);
                      Severity: Major
                      Found in app/js-yui/building/transporter.js - About 45 mins to fix

                        Function Tile has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            var Tile = function(x, y, z, ox, oy, layer) {
                        Severity: Minor
                        Found in app/js-yui/mapper.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

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

                            Function StarTile has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                Mapper.StarTile = function(x, y, z, ox, oy, layer) {
                            Severity: Minor
                            Found in app/js-yui/mapper.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              if(Dom.getStyle("tradePushPrisonerName", "display") == "none") {
                                                                  Dom.setStyle("tradePushPrisonerName", "display", "block");
                                                                  this.getPrisoners();
                                                              }
                                                              else {
                              Severity: Major
                              Found in app/js-yui/building/transporter.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if(Lang.isArray(resource)) {
                                                            optGroup = document.createElement("optgroup");
                                                            optGroup.label = r.titleCaps();
                                                            
                                                            for(var x=0; x < resource.length; x++) {
                                Severity: Major
                                Found in app/js-yui/building/transporter.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if(total > 0) {
                                                outChance.splice(5, 0, '<li><label>Total:</label> ');
                                                outChance.splice(6, 0, parseInt(total));
                                                outChance.splice(7, 0, '</li>');
                                              }
                                  Severity: Major
                                  Found in app/js-yui/building/archaeology.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                                    if(Dom.getStyle("tradePushPlanName", "display") == "none") {
                                                                        Dom.setStyle("tradePushPlanName", "display", "block");
                                                                        this.getPlans();
                                                                    }
                                                                    else {
                                    Severity: Major
                                    Found in app/js-yui/building/transporter.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if(tile) {
                                                                  if(tile.data && tile.data.name) {
                                                                      if(planets.hasOwnProperty(tile.data.name)) {
                                                                          if(Lacuna.MapStar._map.tileCache[tile.x] && Lacuna.MapStar._map.tileCache[tile.x][tile.y]) {
                                                                              delete Lacuna.MapStar._map.tileCache[tile.x][tile.y]; // Remove the planet from the cache
                                      Severity: Major
                                      Found in app/js-yui/mapper.js - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language