Showing 120 of 205 total issues
Method keyDown
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public boolean keyDown(int keycode) {
if (Globals.chat.isOpen()) {
return false;
}
Method render
has a Cognitive Complexity of 12 (exceeds 5 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));
- 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 12 (exceeds 5 allowed). Consider refactoring. Open
public void update(int dt) {
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 canHold
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
default boolean canHold(ItemHolder holder) {
switch (getType()) {
case ANY:
case TRASH:
default:
Method load
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void load(String playerName) {
String fileName = Files.getPlayerSave(playerName);
File file = new File(fileName);
if (!file.exists()) {
Method onStateChange
has 34 lines of code (exceeds 25 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)) {
Consider simplifying this complex logical expression. Open
if ((t == null || !t.isSolid()) && (b == null || !b.isSolid()) && (r == null || !r.isSolid())
&& (l == null || !l.isSolid())) {
Wall wall = Globals.getWorld().walls.get(x, y);
Method run
has 33 lines of code (exceeds 25 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.
Method save
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void save(int x, int y) {
String fileName = Files.getChunkSave(x, y);
File file = new File(fileName);
if (!file.exists()) {
try {
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 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 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 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 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 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 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];
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);