Showing 594 of 594 total issues
Function inPositions
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
RoomPosition.prototype.inPositions = function() {
const room = this.getRoom();
if (!room.data.positions) {
return false;
}
- 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 getCostMatrix
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.getCostMatrix = function() {
const costMatrix = new PathFinder.CostMatrix();
// Keep distance to walls
for (let x = 0; x < 50; x++) {
for (let y = 0; y < 50; y++) {
- 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 buildRoads
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Creep.buildRoads = function(creep) {
const room = Game.rooms[creep.room.name];
// TODO extract to RoomPosition
/**
- 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 checkExitsAreReachable
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.checkExitsAreReachable = function() {
// Make sure every exit is reachable
const inLayer = function(room, pos) {
for (let i = 0; i < room.memory.walls.layer_i; i++) {
- 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
File find.js
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
Room.prototype.findHostileStructureWithEnergy = function() {
return this.find(FIND_HOSTILE_STRUCTURES, {
filter: (object) => object.store && object.store.energy,
Function prepareBoost
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function prepareBoost(creep) {
for (const creepName of Object.keys(creep.room.memory.boosts)) {
const config = creep.room.memory.boosts[creepName];
if (config.time + 1500 < Game.time) {
creep.room.debugLog('boosts', `Deleting old config ${JSON.stringify(config)}`);
- 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 prepareBoosting
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function prepareBoosting(room, creep, config) {
if (!room.terminal || !room.terminal.my) {
return false;
}
- 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 cleanSetTargetId
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Creep.prototype.cleanSetTargetId = function() {
if (!this.room.isMy()) {
// this.log('no targetId');
if (this.cleanController()) {
// this.log('clean controller');
- 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 setupStructure
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.setupStructure = function(structure) {
const constructionSites = this.find(FIND_CONSTRUCTION_SITES, {filter: (object) => object.structureType === structure});
if (setupStructureFinishPriorityStructures(structure, constructionSites)) {
return true;
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
updateCreeps: function(event, status) {
const creeps = _.filter(event.data.objects, filter.creeps);
if (_.size(creeps) > 0) {
status[event.id].creeps += _.size(creeps);
}
- 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 86.
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
updateStructures: function(event, status) {
const structures = _.filter(event.data.objects, filter.structures);
if (_.size(structures) > 0) {
status[event.id].structures += _.size(structures);
}
- 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 86.
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 action
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
roles.atkeepermelee.action = function(creep) {
// TODO Untested
creep.spawnReplacement();
creep.setNextSpawn();
creep.memory.canHeal = creep.getActiveBodyparts(HEAL) > 0;
Function showStructures
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
showStructures() {
for (const room of _.values(Game.rooms)) {
if (!room.isMy()) {
continue;
}
- 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 showCostMatrix
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
showCostMatrix(roomName, costMatrixCallback) {
const rv = new RoomVisual(roomName);
const cm = costMatrixCallback(roomName);
if (cm) {
for (let x = 0; x < 50; ++x) {
- 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 showBlockers
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
showBlockers() {
for (const room of _.values(Game.rooms)) {
if (!room.isMy()) {
continue;
}
- 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 checkPlayers
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function checkPlayers() {
if (Game.time % config.diplomacy.checkPlayersInterval !== 0) {
return;
}
Memory.players = Memory.players || {};
- 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 preMove
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
roles.squadsiege.preMove = function(creep, directions) {
// creep.log('preMove');
if (!directions) {
return false;
}
- 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 destroyStructureWall
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Room.prototype.destroyStructureWall = function(structure) {
if (!structure.hits) {
return false;
}
if (!this.memory.walls) {
- 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 action
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
roles.atkeeper.action = function(creep) {
// TODO Untested
creep.spawnReplacement();
creep.setNextSpawn();
const center = new RoomPosition(25, 25, creep.memory.routing.targetRoom);
Function defendTower
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
roles.nextroomer.defendTower = function(creep) {
const room = Game.rooms[creep.room.name];
const constructionSites = creep.pos.findInRange(FIND_CONSTRUCTION_SITES, 1);
if (constructionSites.length > 0) {
creep.build(constructionSites[0]);
- 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"