Showing 205 of 205 total issues
Similar blocks of code found in 4 locations. Consider refactoring. Open
for (int i = 78; i < 83; i++) { // Accessories Dyes
this.slots[i] = new UiItemSlot(new Rectangle(118, 10 + (i - 78) * 54, 52, 52), UiItemSlot.Type.DYE,
Origin.BOTTOM_RIGHT, new TextureRegion(Assets.getTexture("inventory_icons"), 34, 0, 34, 34), i);
}
- 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
Method canBeUsed
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public boolean canBeUsed(short x, short y) {
if (!super.canBeUsed(x, y)) {
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
Method update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public void update(int dt) {
for (Entity entity : this.clearList) {
this.entities.remove(entity);
if (entity instanceof Creature) {
- 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 canHold
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
default boolean canHold(ItemHolder holder) {
switch (getType()) {
case ANY:
case TRASH:
default:
- 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 render
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void render() {
super.render();
this.updateItems();
- 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 add
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
default boolean add(ItemHolder holder) {
// TODO: check if item is already in inventory
for (int i = 0; i < getMaxInventorySize(); i++) {
Slot slot = getSlot(i);
// If slot is empty or slot is full skip consideration.
- 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 load
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void load() {
try {
JsonReader jsonReader = new JsonReader();
JsonValue root = jsonReader.parse(Gdx.files.internal("data/biomes.json"));
Method render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void render() {
if (this.hidden) {
return;
}
Method loadAnimation
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private void loadAnimation(JsonValue root, String type) {
JsonValue animation = root.get(type);
Animation to = this.animations[this.toID(type)];
if (animation.has("copy")) {
- 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 render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void render() {
boolean displayedStats = false;
int halfWidth = Gdx.graphics.getWidth() / 2;
int halfHeight = Gdx.graphics.getHeight() / 2;
Method render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void render(float delta) {
Graphics.batch.setColor(1, 1, 1, this.alpha);
Graphics.batch.draw(this.splash, (Gdx.graphics.getWidth() - this.splash.getWidth()) / 2,
(Gdx.graphics.getHeight() - this.splash.getHeight()) / 2);
Method loadFields
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void loadFields(JsonValue root) {
this.spawnInfo = new SpawnInfo(root.getShort("spawnRate", (short) 700), root.getShort("maxSpawns", (short) 5));
this.biomeVector = new Vector2(root.getShort("temperature", (short) 50), root.getShort("humidity", (short) 50));
this.level = root.getByte("level", (byte) 0);
this.materials = BiomeMaterials.read(root.get("materials"));
Method create
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Creature create() {
Enemy creature = new Enemy(this.id, this.ai);
int hp = this.hp[0];
int defense = this.damage[0];
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i = 50; i < 54; i++) { // Coins
this.slots[i] = new UiItemSlot(new Rectangle(x + 542, y + 100 + (i - 50) * 34, 32, 32),
UiItemSlot.Type.COIN, i);
}
- 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 74.
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 (int i = 54; i < 58; i++) { // Ammo
this.slots[i] = new UiItemSlot(new Rectangle(x + 576, y + 100 + (i - 54) * 34, 32, 32),
UiItemSlot.Type.AMMO, i);
}
- 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 74.
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
Method overlay
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void overlay(Pixmap pixmap, Color color) {
ByteBuffer bb = pixmap.getPixels();
final float rTint = color.r;
final float bTint = color.b;
Method generateEligibleEnemySpawnPoint
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Optional<GenericContainer.Pair<Integer>> generateEligibleEnemySpawnPoint(
CircleAreaComponent enemySpawnArea) {
GenericContainer.Pair<Integer> minAndMaxDists = retrieveMinMaxDistances(enemySpawnArea);
Method create
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public static byte create(boolean b1, boolean b2, boolean b3, boolean b4,
boolean b5, boolean b6, boolean b7, boolean b8) {
Method render
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void render(float delta) {
Graphics.batch.setColor(1, 1, 1, this.alpha);
Graphics.batch.draw(this.splash, (Gdx.graphics.getWidth() - this.splash.getWidth()) / 2,
(Gdx.graphics.getHeight() - this.splash.getHeight()) / 2);
- 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 save
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static void save() {
File dir = new File(Files.getPlayersDir());
if (!dir.exists()) {
dir.mkdir();
- 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"