Showing 120 of 205 total issues
Method initCommands
has 149 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void initCommands() {
this.commands.register(new Command("help", "Shows a list of existing chat commands", CMDCategory.GAME) {
@Override
public void onRun(String[] args) {
// TODO: Hide commands based on user permissions.
Method updateXVelocity
has a Cognitive Complexity of 39 (exceeds 5 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);
- 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 updateYVelocity
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
private void updateYVelocity() {
if (this.solid) {
// Apply gravity
this.velocity.y -= 0.4f;
}
- 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
PhysicsComponent
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
public class PhysicsComponent<T extends Entity> extends EntityComponent<T> {
public enum Direction {
LEFT, RIGHT
}
Method onStateChange
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected void onStateChange() {
UiInventory inventory = Globals.getPlayer().getInventory();
if (this.state == State.MOUSE_DOWN && inventory.isOpen()) {
if (InputManager.isMouseButtonPressed(Input.Buttons.LEFT)) {
- 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
Chunk
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
public class Chunk {
public static final int SIZE = 256;
public static final int TOTAL_SIZE = 256 * 256;
private ChunkData data;
Method renderLiquid
has a Cognitive Complexity of 27 (exceeds 5 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) {
- 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 get
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public float get(int x, int y) {
if (LastTry.noLight) {
return 1f;
}
// Check cache if light for the tile has been calculated already.
- 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
World
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
public class World {
// Should be 20 by default
public static final int UPDATE_DELAY_SECONDS = 20;
public static final int RESPAWN_DELAY = 360;
/**
Method load
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private void load(JsonValue root) throws Exception {
if (root.has("hp")) {
this.hp = root.get("hp").asIntArray();
}
- 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 updateItems
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private void updateItems() {
if (InputManager.isMouseButtonPressed(Input.Buttons.LEFT)
|| InputManager.isMouseButtonPressed(Input.Buttons.RIGHT)) {
if (this.isOpen()) {
- 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 updateBiome
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private void updateBiome() {
if (Globals.getWorld() == null) {
return;
}
- 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 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void load(JsonValue root) throws Exception {
if (root.has("hp")) {
this.hp = root.get("hp").asIntArray();
}
UiChat
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
public class UiChat extends UiPanel implements UiScreen, UiToggleScreen {
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
/**
* Chat is open
Method run
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void run(WorldGenerator generator) {
logger.info("Generating caves");
// TODO: These numbers shouldn't be hard-coded
// TODO: Let the user choose these variables when generating a world.
- 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 20 (exceeds 5 allowed). Consider refactoring. Open
public void render() {
Rectangle blocksRect = Camera.getBlocksOnScreen();
for (int y = blocksRect.y; y < blocksRect.y + blocksRect.height; y++) {
for (int x = blocksRect.x; x < blocksRect.x + blocksRect.width; 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
File PhysicsComponent.java
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
package org.egordorichev.lasttry.entity.components;
import com.badlogic.gdx.math.Vector2;
import org.egordorichev.lasttry.Globals;
import org.egordorichev.lasttry.entity.Entity;
Method pushOutOfBlocks
has a Cognitive Complexity of 19 (exceeds 5 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)) {
- 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 UiInventory.java
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
package org.egordorichev.lasttry.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
Item
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
public class Item {
private static final Logger logger = LoggerFactory.getLogger(Item.class);
/**
* Item identifier.
*/