egordorichev/LastTry

View on GitHub

Showing 205 of 205 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public int getClickY() {
        switch (this.origin) {
            case TOP_LEFT:
            case TOP_RIGHT:
            default:
Severity: Major
Found in core/src/org/egordorichev/lasttry/ui/UiComponent.java and 1 other location - About 1 hr to fix
core/src/org/egordorichev/lasttry/ui/UiComponent.java on lines 83..95

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

Further Reading

Method save has 37 lines of code (exceeds 25 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 1 hr to fix

    Method updateYVelocity has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private void updateYVelocity() {
            if (this.solid) {
                // Apply gravity
                this.velocity.y -= 0.4f;
            }

      Method get has 37 lines of code (exceeds 25 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.

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

          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));
          
          
          Severity: Minor
          Found in core/src/org/egordorichev/lasttry/state/GamePlayState.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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              @Override
              public void load(){
                  try {
                      JsonReader jsonReader = new JsonReader();
                      JsonValue root = jsonReader.parse(Gdx.files.internal("data/items.json"));
          Severity: Major
          Found in core/src/org/egordorichev/lasttry/item/ItemManagerImpl.java and 1 other location - About 1 hr to fix
          core/src/org/egordorichev/lasttry/effect/EffectManagerImpl.java on lines 21..38

          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 95.

          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

              public void load() {
          
                  try {
                      JsonReader jsonReader = new JsonReader();
                      JsonValue root = jsonReader.parse(Gdx.files.internal("data/effects.json"));
          core/src/org/egordorichev/lasttry/item/ItemManagerImpl.java on lines 22..39

          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 95.

          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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public void update(int dt) {
                  if (Globals.getWorld() == null) {
                      return;
                  }
          
          

          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

                  this.commands.register(new Command("startset", "Gives you a start set", CMDCategory.DEBUG) {
                      @Override
                      public void onRun(String[] args) {
                          Globals.getPlayer().getInventory().clear();
                          Globals.getPlayer().getInventory().add(new ItemHolder(itemManager.getItem("lt:copper_shortsword"), 1));
          Severity: Major
          Found in core/src/org/egordorichev/lasttry/ui/chat/UiChat.java and 1 other location - About 1 hr to fix
          core/src/org/egordorichev/lasttry/ui/chat/UiChat.java on lines 188..196

          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 92.

          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

                  this.commands.register(new Command("devset", "Gives you a dev set", CMDCategory.DEBUG) {
                      @Override
                      public void onRun(String[] args) {
                          Globals.getPlayer().getInventory().clear();
                          Globals.getPlayer().getInventory().add(new ItemHolder(itemManager.getItem("lt:superpick"), 1));
          Severity: Major
          Found in core/src/org/egordorichev/lasttry/ui/chat/UiChat.java and 1 other location - About 1 hr to fix
          core/src/org/egordorichev/lasttry/ui/chat/UiChat.java on lines 198..206

          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 92.

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

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

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

                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);
                
                
                Severity: Critical
                Found in core/src/org/egordorichev/lasttry/item/block/Block.java - About 1 hr to fix

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

                      Similar blocks of code found in 4 locations. Consider refactoring.
                      Open

                              for (int i = 65; i < 68; i++) { // Armor Dye
                                  this.slots[i] = new UiItemSlot(new Rectangle(118, 280 + (i - 65) * 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 89..92
                      core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 94..98
                      core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 100..103

                      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

                      Similar blocks of code found in 4 locations. Consider refactoring.
                      Open

                              for (int i = 68; i < 73; i++) { // Accessories
                                  this.slots[i] = new UiItemSlot(new Rectangle(10, 10 + (i - 68) * 54, 52, 52), UiItemSlot.Type.ACCESSORY,
                                          Origin.BOTTOM_RIGHT, new TextureRegion(Assets.getTexture("inventory_icons"), 68, 34, 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 94..98
                      core/src/org/egordorichev/lasttry/ui/UiInventory.java on lines 100..103

                      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

                      Similar blocks of code found in 4 locations. Consider refactoring.
                      Open

                              for (int i = 73; i < 78; i++) { // Vanity Accessories
                                  this.slots[i] = new UiItemSlot(new Rectangle(64, 10 + (i - 73) * 54, 52, 52),
                                          UiItemSlot.Type.VANITY_ACCESSORY, Origin.BOTTOM_RIGHT,
                                          new TextureRegion(Assets.getTexture("inventory_icons"), 68, 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 100..103

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language