egordorichev/LastTry

View on GitHub

Showing 120 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) {
Severity: Major
Found in core/src/org/egordorichev/lasttry/item/liquids/LiquidManagerImpl.java - About 2 hrs to fix

    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;
    Severity: Minor
    Found in core/src/org/egordorichev/lasttry/ui/chat/UiChat.java - About 2 hrs to fix

      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()) {
      Severity: Major
      Found in core/src/org/egordorichev/lasttry/world/chunk/ChunkIO.java - About 2 hrs to fix

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

              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++) {

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

                Method keyDown has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            @Override
                            public boolean keyDown(int keycode) {
                                if (ignoreInput) {
                                    return false;
                                }
                Severity: Minor
                Found in core/src/org/egordorichev/lasttry/ui/UiTextInputWithHistory.java - About 1 hr to fix

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

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

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

                          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"));
                          Severity: Minor
                          Found in core/src/org/egordorichev/lasttry/world/biome/Biome.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 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;
                          Severity: Minor
                          Found in core/src/org/egordorichev/lasttry/world/World.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 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;
                          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 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.
                                Severity
                                Category
                                Status
                                Source
                                Language