Kuangcp/JavaBase

View on GitHub

Showing 221 of 349 total issues

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;
    
    

      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

                Tank has 24 methods (exceeds 20 allowed). Consider refactoring.
                Open

                @Slf4j
                public abstract class Tank extends AbstractLoopEvent implements VisualItem {
                    int x;          // 坦克中心的横坐标
                    int y;          // 坦克中心的纵坐标
                    int direct = 0;   // 初始方向
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/tank/domain/Tank.java - About 2 hrs to fix

                  Method findDiffIndexPoint has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static int findDiffIndexPoint(String a, String b) {
                          if (StringUtils.equals(a, b)) {
                              return 0;
                          }
                          if (Objects.isNull(a)) {

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

                    T in(Class<T> target, InputStream inputStream) {
                      T object = null;
                      try {
                        Reader reader = new InputStreamReader(inputStream);
                        BufferedReader bufferedReader = new BufferedReader(reader);

                  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 TimeWheel.java has 274 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  package com.github.kuangcp.time.wheel;
                  
                  import lombok.extern.slf4j.Slf4j;
                  
                  import java.time.Duration;
                  Severity: Minor
                  Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.java - About 2 hrs to fix

                    Method findDiffIndex has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static int findDiffIndex(String a, String b) {
                            if (StringUtils.equals(a, b)) {
                                return 0;
                            }
                            if (Objects.isNull(a)) {

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

                        public void saveDataBase() {
                            PreparedStatement ps = null;
                            Connection cn = null;
                            ResultSet rs = 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

                    Severity
                    Category
                    Status
                    Source
                    Language