Showing 183 of 183 total issues
Function _clearState
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _clearState() {
_response.partialMessage = "";
if (_request.id) {
clearTimeout(_request.id);
}
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 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 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 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")){
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,
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);
Similar blocks of code found in 3 locations. Consider refactoring. Open
class TextBuilder extends BaseBuilder<TextBuilder> {
private boolean hideScore;
private boolean hideInfo;
- 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 89.
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 3 locations. Consider refactoring. Open
class DeployBuilder extends BaseBuilder<DeployBuilder> {
private UnitType unitType;
private Field field;
- 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 89.
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 3 locations. Consider refactoring. Open
class CombatBuilder extends BaseBuilder<CombatBuilder> {
private Field unit;
private Field field;
- 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 89.
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
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 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
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
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) {