Showing 509 of 1,320 total issues
Consider simplifying this complex logical expression. Open
Open
if (typeof YAHOO.lacuna.buildings.Building == "undefined" || !YAHOO.lacuna.buildings.Building) {
(function(){
var Lang = YAHOO.lang,
Util = YAHOO.util,
Function sendRequest
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
var sendRequest = function(url, data, options, retry) {
console.log('Calling', options.module + '/' + options.method, options.params);
$.ajax({
data : data,
- Read upRead up
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
Open
if(tile) {
if(tile.blank) {
tile.refresh();
}
tile.appendToDom();
Avoid deeply nested control flow statements. Open
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);
Avoid deeply nested control flow statements. Open
Open
else if(resource) {
nOpt = opt.cloneNode(false);
nOpt.value = r;
nOpt.innerHTML = r.titleCaps();
elm.appendChild(nOpt);
Avoid deeply nested control flow statements. Open
Open
if(Lang.isArray(resource)) {
for(x=0; x < resource.length; x++) {
name = resource[x];
if(this.resources[name]) {
nLi = li.cloneNode(false);
Function PlanetTile
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
Mapper.PlanetTile = function(x, y, z, ox, oy, layer) {
Avoid deeply nested control flow statements. Open
Open
if(doSub) {
tile.unsubscribeAll(); //so we don't get multiple subs on the same tile
tile.subscribe("onReload", this.onReloadTile, this, true);
}
Avoid deeply nested control flow statements. Open
Open
if(star.bodies.hasOwnProperty(bKey)){
var body = star.bodies[bKey];
body.isPlanet = true;
if(!this.tileCache[body.x]) {
this.tileCache[body.x] = {};
Avoid deeply nested control flow statements. Open
Open
if (obj.id > 0) {
nLi = li.cloneNode(false);
Dom.addClass(nLi,"excavatorAbandon");
var bbtn = document.createElement("button");
bbtn.setAttribute("type", "button");
Avoid deeply nested control flow statements. Open
Open
if(Dom.getStyle("tradeAddGlyphName", "display") == "none") {
Dom.setStyle("tradeAddGlyphName", "display", "block");
this.getGlyphs();
}
else {
Avoid deeply nested control flow statements. Open
Open
if(Lang.isArray(resource)) {
for(x=0; x < resource.length; x++) {
name = resource[x];
if(this.resources[name]) {
nLi = li.cloneNode(false);
Function Tile
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
var Tile = function(x, y, z, ox, oy, layer) {
Avoid deeply nested control flow statements. Open
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() }) +
Function StarTile
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
Mapper.StarTile = function(x, y, z, ox, oy, layer) {
Avoid deeply nested control flow statements. Open
Open
if(Dom.getStyle("tradePushPrisonerName", "display") == "none") {
Dom.setStyle("tradePushPrisonerName", "display", "block");
this.getPrisoners();
}
else {
Avoid deeply nested control flow statements. Open
Open
if(Lang.isArray(resource)) {
optGroup = document.createElement("optgroup");
optGroup.label = r.titleCaps();
for(var x=0; x < resource.length; x++) {
Avoid deeply nested control flow statements. Open
Open
if(total > 0) {
outChance.splice(5, 0, '<li><label>Total:</label> ');
outChance.splice(6, 0, parseInt(total));
outChance.splice(7, 0, '</li>');
}
Avoid deeply nested control flow statements. Open
Open
if(Dom.getStyle("tradePushPlanName", "display") == "none") {
Dom.setStyle("tradePushPlanName", "display", "block");
this.getPlans();
}
else {
Avoid deeply nested control flow statements. Open
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