egordorichev/LastTry

View on GitHub

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

    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

    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

                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
                          Severity
                          Category
                          Status
                          Source
                          Language