Kuangcp/JavaBase

View on GitHub

Showing 221 of 349 total issues

Method readAll has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void readAll() {
        InputStream input = null;
        BufferedReader br = null;
        InputStreamReader ids = null;
        try {
Severity: Major
Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.java - About 2 hrs to fix

    Expression has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Expression {
    
        private String expression;  //算术表达式字符串
        private final List<ExpressionWord> expressionWord; //存储表达式词法分析所得的单词与该单词所对应的种别编码的集合
        private int index;  //读取词法分析器的字符游标

      File Calculator.java has 263 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package com.github.kuangcp.caculator;
      
      
      import java.awt.Dimension;
      import java.awt.Font;
      Severity: Minor
      Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.java - About 2 hrs to fix

        Method startNewRound has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public void startNewRound() {
                enemyList = new CopyOnWriteArrayList<>();
                bricks = new CopyOnWriteArrayList<>();
                irons = new CopyOnWriteArrayList<>();
        
        
        Severity: Minor
        Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.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 pushTimeWheel has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            private void pushTimeWheel(int seconds) {
                Map<ChronoUnit, Integer> tempIndex = new HashMap<>(sortedSlots.size());
                for (int i = 0; i < sortedSlots.size(); i++) {
                    ChronoUnit unit = sortedSlots.get(i);
                    Integer threshold = slots.get(unit);
        Severity: Minor
        Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.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 startNewRound has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void startNewRound() {
                enemyList = new CopyOnWriteArrayList<>();
                bricks = new CopyOnWriteArrayList<>();
                irons = new CopyOnWriteArrayList<>();
        
        
        Severity: Major
        Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 2 hrs to fix

          File Saved.java has 255 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package com.github.kuangcp.tank.util;
          
          import com.github.kuangcp.tank.domain.Brick;
          import com.github.kuangcp.tank.domain.EnemyTank;
          import com.github.kuangcp.tank.domain.Hero;
          Severity: Minor
          Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.java - About 2 hrs to fix

            Method findEffectiveArea has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                private void findEffectiveArea() {
                    for (int i = 0; i <= 14; i++) {
                        for (int j = 0; j <= 14; j++)
                            if (chess[i][j] != null) {
                                effectiveX1 = i;
            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 quickSort has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              public <T extends Comparable<? super T>> T[] quickSort(T[] data, int start, int end) {
                int low = start + 1, high = end;
                T key = data[start];
            
                if (start >= end) {
            Severity: Minor
            Found in algorithms/src/main/java/com/github/kuangcp/sort/Quick.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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public void run() throws Exception {
                    init();
            //运算出初始的表格
                    display("中间计算结果", Tables);
                    //计算最底下一行

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

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

              Method savedAll has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public void savedAll() {
                      BufferedWriter bw = null;
                      OutputStream out = null;
                      OutputStreamWriter os = null;
              
              
              Severity: Major
              Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.java - About 2 hrs to fix

                Method saveDataBase has 50 lines of code (exceeds 25 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

                  Method ablePass has 50 lines of code (exceeds 25 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 2 hrs to fix

                    Method findDiffIndex has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method paintComponent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          @Override
                          protected void paintComponent(Graphics g) {
                              int offset = 4;
                              int r = 5;
                              int chessR = 20;
                      Severity: Minor
                      Found in gui/src/main/java/com/github/kuangcp/gomoku/ChessBoard.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 sortData has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          @Override
                          public void sortData(int[] data, int low, int high) {
                            int lowIndex = low;
                            int highIndex = high;
                            int index = data[low];
                      Severity: Minor
                      Found in algorithms/src/main/java/com/github/kuangcp/sort/Quick.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 start has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public void start() throws IOException {
                          Selector selector = Selector.open();
                          //通过OPEN方法来打开一个未绑定的ServerSocketChannel 实例
                          ServerSocketChannel server = ServerSocketChannel.open();
                          //将该ServerSocketChannel绑定到指定ip
                      Severity: Minor
                      Found in network/src/main/java/com/github/kuangcp/nio/EchoNIOServer.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 showRows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private void showRows() {
                              StringBuilder MaxRows = new StringBuilder("Max(z)=");
                              for (int i = 0; i < MAX_PARAMS; i++) {
                                  if (!Max.get(i).isZero()) {
                                      MaxRows.append(Max.get(i)).append(" X").append(i + 1).append(" + ");

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

                          public void run() throws Exception {
                              init();
                      //运算出初始的表格
                              display("中间计算结果", Tables);
                              //计算最底下一行
                        Severity
                        Category
                        Status
                        Source
                        Language