Showing 205 of 205 total issues
Method renderLiquid
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void renderLiquid(int x, int y) {
byte hp = Globals.getWorld().blocks.getHP(x, y);
byte liquidLevel = BlockHelper.empty.getLiquidLevel(hp);
if (liquidLevel > 0) {
File UiChat.java
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
package org.egordorichev.lasttry.ui.chat;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
Method load
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Chunk load(int x, int y) {
String fileName = Files.getChunkSave(x, y);
File file = new File(fileName);
if (!file.exists()) {
Method updateXVelocity
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateXVelocity() {
// Non-solids skip adjustment and collision checks
if (this.solid && this.velocity.x != 0) {
// this.pushOutOfBlocks(Util.random(1, 5));
Rectangle originalHitbox = this.hitbox.copy().offset(this.position);
Method load
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static Chunk load(int x, int y) {
String fileName = Files.getChunkSave(x, y);
File file = new File(fileName);
if (!file.exists()) {
- 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 pushOutOfBlocks
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean pushOutOfBlocks(int i) {
Rectangle box = this.hitbox.copy().offset(this.position);
float offsetSize = Block.SIZE;
boolean pushed = false;
if (collides(box)) {
Method noise
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static double noise(double xin, double yin) {
double n0, n1, n2; // Noise contributions from the three corners
// Skew the input space to determine which simplex cell we're in
final double F2 = 0.5 * (Math.sqrt(3.0) - 1.0);
double s = (xin + yin) * F2; // Hairy factor for 2D
Method calculateNeighbors
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected int calculateNeighbors(WorldGenerator generator, boolean[][] terrain, int x, int y) {
int neighbors = 0;
int w = generator.getWorldWidth();
int h = generator.getWorldHeight();
for (int j = y - 1; j < y + 2; j++) {
- 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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT |
(Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));
Method keyDown
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean keyDown(int keycode) {
if (ignoreInput) {
return false;
}
Method load
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void load(String name) {
String fileName = Files.getWorldSave(name);
File file = new File(fileName);
if (!file.exists()) {
Method run
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void run() {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
Method updateBiome
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateBiome() {
if (Globals.getWorld() == null) {
return;
}
Method save
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void save() {
World world = Globals.getWorld();
String fileName = Files.getWorldSave(world.getName());
File file = new File(fileName);
Method loadFields
has a Cognitive Complexity of 13 (exceeds 5 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"));
- 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 isColliding
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public boolean isColliding(Rectangle bounds) {
Rectangle gridBounds = bounds.copy();
gridBounds.x /= Block.SIZE;
gridBounds.y /= Block.SIZE;
gridBounds.width /= Block.SIZE;
- 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 13 (exceeds 5 allowed). Consider refactoring. Open
public void render() {
boolean displayedStats = false;
int halfWidth = Gdx.graphics.getWidth() / 2;
int halfHeight = Gdx.graphics.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
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i = 59; i < 62; i++) { // Armor
this.slots[i] = new UiItemSlot(new Rectangle(10, 280 + (i - 59) * 54, 52, 52), UiItemSlot.Type.ARMOR,
Origin.BOTTOM_RIGHT,
new TextureRegion(Assets.getTexture("inventory_icons"), 0, 68 - (i - 59) * 34, 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 100.
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 = 62; i < 65; i++) { // Vanity Armor
this.slots[i] = new UiItemSlot(new Rectangle(64, 280 + (i - 62) * 54, 52, 52), UiItemSlot.Type.VANITY,
Origin.BOTTOM_RIGHT,
new TextureRegion(Assets.getTexture("inventory_icons"), 0, 170 - (i - 62) * 34, 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 100.
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
public int getX() {
switch (this.origin) {
case TOP_LEFT:
case BOTTOM_LEFT:
default:
- 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 99.
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