File game.jsx
has 798 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
YAHOO.namespace('lacuna');
var React = require('react');
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
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';
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;
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() {
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;
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 };
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;
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);
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;
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++;
Function isEventSupported
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var isEventSupported = (function() {
var TAGNAMES = {
'select' : 'input',
'change' : 'input',
'submit' : 'form',
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];
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;
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;
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;
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;
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;
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) {
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,
Avoid deeply nested control flow statements. Open
if (planet.happiness < 0 && ED.is_isolationist === '1') {
planet.happiness = 0;
}
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76