Kuangcp/JavaBase

View on GitHub

Showing 349 of 349 total issues

File TankGroundPanel.java has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.github.kuangcp.tank.panel;

import com.github.kuangcp.tank.domain.Brick;
import com.github.kuangcp.tank.domain.Bullet;
import com.github.kuangcp.tank.domain.EnemyTank;
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 3 hrs to fix

    Method ablePass has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public static boolean ablePass(Tank t, Hinder h) {
            int hx = h.getWidth(), hy = h.getHeight();
            final int halfHeight = t.getHalfHeight();
            final int halfWidth = t.getHalfWidth();
    
    
    Severity: Minor
    Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 3 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

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

                for (int i = 0; i < et.bulletList.size(); i++) {
                    Bullet myBullet = et.bulletList.get(i);
                    for (Brick brick : bricks) {
                        TankTool.judgeHint(myBullet, brick);
                    }
    gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java on lines 209..230

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

    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 = 0; i < hero.bulletList.size(); i++) {
                Bullet myBullet = hero.bulletList.get(i);
                for (Brick brick : bricks) {
                    TankTool.judgeHint(myBullet, brick);
                }
    gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java on lines 243..263

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

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

      public int[] sort(int[] data) {
        int[] arr = Arrays.copyOf(data, data.length);
    
        List<List<Integer>> dataList = new ArrayList<>();
        List<Integer> arrs = new ArrayList<>();
    Severity: Minor
    Found in algorithms/src/main/java/com/github/kuangcp/sort/Shell.java - About 3 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 run has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public void run(){
            try{
                br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                ps = new PrintStream(socket.getOutputStream());
                String line = null;

    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 main has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static void main(String[] args) {
            for (int k = 0; k < minSize; k++) {
                stack[k] = new Point();
                path[k] = new Point();
            }

      Method countToScore has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private int countToScore(int count, int block, Color color) {
              if (block == 2)
                  return 0;
              if (count == 5 && color == myColor)
                  return 0x3b9aca00;
      Severity: Minor
      Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.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 readAll has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public void readAll() {
              InputStream input = null;
              BufferedReader br = null;
              InputStreamReader ids = null;
              try {
      Severity: Minor
      Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.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 getPostfix has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public static List<ExpressionWord> getPostfix(Expression expression) {
              List<ExpressionWord> midfix = expression.getWord();  //获取中缀表达式的经过词法分析器分析的结果集
              List<ExpressionWord> result = new ArrayList<>();   //存储后缀表达式结果的List集合
              Stack<ExpressionWord> operationStack = new Stack<>();  //操作符栈
      
      

      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

      File SimplexMethodWithFraction.java has 288 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package com.github.kuangcp.simplex.method;
      
      import com.github.kuangcp.math.number.Fraction;
      import lombok.extern.slf4j.Slf4j;
      
      

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

                    case DirectType.DOWN:
                        final int downY = t.getY() + halfHeight;
                        if (leftX >= h.getHx() && leftX <= h.getHx() + hx
                                && downY >= h.getHy() && downY <= h.getHy() + hy
                                || t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
        Severity: Major
        Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java and 1 other location - About 2 hrs to fix
        gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java on lines 181..191

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

        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

                    case DirectType.UP:
                        final int upY = t.getY() - halfHeight;
                        if (leftX >= h.getHx() && leftX <= h.getHx() + hx
                                && upY >= h.getHy() && upY <= h.getHy() + hy
                                || t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
        Severity: Major
        Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java and 1 other location - About 2 hrs to fix
        gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java on lines 192..202

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

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

            public void savedAll() {
                BufferedWriter bw = null;
                OutputStream out = null;
                OutputStreamWriter os = null;
        
        
        Severity: Minor
        Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.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 handleNotification has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

                        @Override
                        public void handleNotification(Notification notification, Object handback) {
                            //we only handle GARBAGE_COLLECTION_NOTIFICATION notifications here
                            if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
                                //get the information associated with this notification
        Severity: Minor
        Found in class/src/main/java/jvm/gc/MxBeanCallback.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 paint has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void paint(Graphics g) {
                super.paint(g);
        
                if (Objects.isNull(hero)) {
                    hero = new Hero(20, 20, 4);
        Severity: Major
        Found in gui/src/main/java/com/github/kuangcp/tank/v1/MainPanelV1.java - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                          if (t.getX() - halfHeight >= h.getHx() && t.getX() - halfHeight <= h.getHx() + hx
                                  && t.getY() - halfWidth >= h.getHy() && t.getY() - halfWidth <= h.getHy() + hy
                                  || t.getX() - halfHeight >= h.getHx() && t.getX() - halfHeight <= h.getHx() + hx
                                  && t.getY() >= h.getHy() && t.getY() <= h.getHy() + hy
                                  || t.getX() - halfHeight >= h.getHx() && t.getX() - halfHeight <= h.getHx() + hx
          Severity: Critical
          Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                            if (leftX >= h.getHx() && leftX <= h.getHx() + hx
                                    && upY >= h.getHy() && upY <= h.getHy() + hy
                                    || t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
                                    && upY >= h.getHy() && upY <= h.getHy() + hy
                                    || rightX >= h.getHx() && rightX <= h.getHx() + hx
            Severity: Critical
            Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                              if (leftX >= h.getHx() && leftX <= h.getHx() + hx
                                      && downY >= h.getHy() && downY <= h.getHy() + hy
                                      || t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
                                      && downY >= h.getHy() && downY <= h.getHy() + hy
                                      || rightX >= h.getHx() && rightX <= h.getHx() + hx
              Severity: Critical
              Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                                if (t.getX() + halfHeight >= h.getHx() - 2 && t.getX() + halfHeight <= h.getHx() + hx
                                        && t.getY() + halfWidth >= h.getHy() && t.getY() + halfWidth <= h.getHy() + hy
                                        || t.getX() + halfHeight >= h.getHx() - 2 && t.getX() + halfHeight <= h.getHx() + hx
                                        && t.getY() >= h.getHy() && t.getY() <= h.getHy() + hy
                                        || t.getX() + halfHeight >= h.getHx() - 2 && t.getX() + halfHeight <= h.getHx() + hx
                Severity: Critical
                Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language