egordorichev/LastTry

View on GitHub

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);
        }
Severity: Major
Found in core/src/org/egordorichev/lasttry/ui/UiInventory.java and 3 other locations - About 1 hr to fix
core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 84..87
core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 89..92
core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 94..98

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

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;
        }

Severity: Minor
Found in core/src/org/egordorichev/lasttry/item/block/Block.java - About 1 hr to fix

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) {
Severity: Minor
Found in core/src/org/egordorichev/lasttry/entity/EntityManager.java - About 1 hr to fix

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:
Severity: Minor
Found in core/src/org/egordorichev/lasttry/inventory/InventorySlot.java - About 1 hr to fix

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();

Severity: Minor
Found in core/src/org/egordorichev/lasttry/ui/UiInventory.java - About 1 hr to fix

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.
Severity: Minor
Found in core/src/org/egordorichev/lasttry/inventory/Inventory.java - About 1 hr to fix

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"));
Severity: Minor
Found in core/src/org/egordorichev/lasttry/world/biome/BiomeManagerImpl.java - About 1 hr to fix

    Method render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public void render() {
            if (this.hidden) {
                return;
            }
    Severity: Minor
    Found in core/src/org/egordorichev/lasttry/ui/UiItemSlot.java - About 1 hr to fix

      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")) {
      Severity: Minor
      Found in core/src/org/egordorichev/lasttry/entity/CreatureInfo.java - About 1 hr to fix

      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;
      Severity: Minor
      Found in core/src/org/egordorichev/lasttry/entity/EntityManager.java - About 1 hr to fix

        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);
        Severity: Minor
        Found in core/src/org/egordorichev/lasttry/state/SplashState.java - About 1 hr to fix

          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"));
          Severity: Minor
          Found in core/src/org/egordorichev/lasttry/world/biome/Biome.java - About 1 hr to fix

            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];
            Severity: Minor
            Found in core/src/org/egordorichev/lasttry/entity/CreatureInfo.java - About 1 hr to fix

              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);
                      }
              Severity: Major
              Found in core/src/org/egordorichev/lasttry/ui/UiInventory.java and 1 other location - About 1 hr to fix
              core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 63..66

              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

              Further Reading

              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);
                      }
              Severity: Major
              Found in core/src/org/egordorichev/lasttry/ui/UiInventory.java and 1 other location - About 1 hr to fix
              core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 58..61

              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

              Further Reading

              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;
              Severity: Minor
              Found in core/src/org/egordorichev/lasttry/player/skin/PlayerRenderer.java - About 1 hr to fix

                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) {
                  Severity: Major
                  Found in core/src/org/egordorichev/lasttry/util/ByteHelper.java - About 1 hr to fix

                    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);
                    Severity: Minor
                    Found in core/src/org/egordorichev/lasttry/state/SplashState.java - About 55 mins to fix

                    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();
                    Severity: Minor
                    Found in core/src/org/egordorichev/lasttry/player/PlayerIO.java - About 55 mins to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language