Showing 102 of 183 total issues
Method resolveBattle
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected void resolveBattle(Unit u1, Unit u2, boolean crossing) {
int for1 = isFortified(u1);
int for2 = isFortified(u2);
int sup1 = isSupported(u1);
int sup2 = isSupported(u2);
- 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
Function loop
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var loop = function(){
// check for new or deleted props
for(var i=0; i<lengthsubjects.length; i++) {
Function draw
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Field.prototype.draw = function(ctx, showCoordinates) {
var x = this.x;
var y = this.y;
var width = this.width;
var height = this.height;
Function _attachHeaders
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _attachHeaders(request, url) {
var rq = _request;
if ((request != null) && (typeof (request) !== 'undefined')) {
rq = request;
}
Function defineArrayMethodWatcher
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var defineArrayMethodWatcher = function (obj, original, methodName, callback) {
defineProp(obj, methodName, function () {
var index = 0;
var i,newValue, oldValue, response;
// get values before splicing array
Function _clearState
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _clearState() {
_response.partialMessage = "";
if (_request.id) {
clearTimeout(_request.id);
}
Function draw
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
HandItem.prototype.draw = function(ctx, x, y) {
this.width = Constants.size.width*.8;
this.height = Constants.size.height*.8;
this.x = x;
this.y = y;
Function fn
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
var level,fn = function(prop, action, newValue, oldValue) {
var timerID = getTimerID();
if (lastTimerID!==timerID) { // check if timer has changed since last update
lastTimerID = timerID;
change = {
Method resolveBattle
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void resolveBattle(Unit u1, Unit u2, boolean crossing) {
int for1 = isFortified(u1);
int for2 = isFortified(u2);
int sup1 = isSupported(u1);
int sup2 = isSupported(u2);
Function _getPushRequest
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _getPushRequest(message) {
var msg = _getStringMessage(message);
var rq = {
connected: false,
Function getObjDiff
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
var getObjDiff = function(a, b){
var aplus = [],
bplus = [];
if(!(typeof a == "string") && !(typeof b == "string")){
Consider simplifying this complex logical expression. Open
if (zero(thisX, fx) && minus(thisY, fy) || plus(thisX, fx) && minus(thisY, fy)
|| zero(thisX, fx) && plus(thisY, fy) || plus(thisX, fx) && plus(thisY, fy)) {
return true;
}
Consider simplifying this complex logical expression. Open
if (minus(thisX, fx) && minus(thisY, fy) || zero(thisX, fx) && minus(thisY, fy)
|| minus(thisX, fx) && plus(thisY, fy) || zero(thisX, fx) && plus(thisY, fy)) {
return true;
}
Function storage
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
storage: function () {
function onstorage(event) {
// When a deletion, newValue initialized to null
if (event.key === name && event.newValue) {
listener(event.newValue);
Function draw1
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Unit.prototype.draw1 = function(ctx) {
var x = this.x;
var y = this.y;
var width = this.width;
var height = this.height;
Function defineGetAndSet
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
var defineGetAndSet = function (obj, propName, getter, setter) {
try {
Object.observe(obj, function(changes) {
changes.forEach(function(change) {
if (change.name === propName) {
Method draft
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void draft() {
DraftPhase draftPhase = (DraftPhase) game.getCurrentPhase();
int cheaptestUnit = UnitType.INFANTERY.getCost();
while (player.getCredits() > cheaptestUnit) {
- 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
Method getMovableFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private Set<Field> getMovableFields(CommandCenter cc) {
/*
* A unit can move to all neighbors if no own unit has a FORTIFY or MOVE
* on/to this field
*/
- 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
Function drawArrow
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function drawArrow(ctx, fromx, fromy, tox, toy, color, onlyHeads){
//variables to be used when creating the arrow
var headlen = 4;
var angle = Math.atan2(toy-fromy,tox-fromx);
Function onerror
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_sse.onerror = function (message) {
_debug("sse.onerror");
clearTimeout(_request.id);
if (_request.heartbeatTimer) {