Kuangcp/JavaBase

View on GitHub

Showing 349 of 349 total issues

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 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 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 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 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 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 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);
                    //计算最底下一行

              Method maxList has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public Integer maxList(List<Fraction> list, boolean isMax, boolean haveInfinity, boolean permitMinus) {
                      Integer index = null;
                      //有非数的集合
                      if (haveInfinity) {
                          Map<Integer, Fraction> tempMap = new HashMap<>();

                Method check has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static boolean check(Color chess[][], int x, int y, Color color) {
                        int count = 0;
                        int tempX = x;
                        int tempY = y;
                        for (; contains(chess, x - 1, y, color); x--)
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/gomoku/CheckWin.java - About 1 hr to fix

                  Method btnZeroActionPerformed has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    void btnZeroActionPerformed(ActionEvent e) {
                      if (flag) { //如果刚刚按下了运算符
                        txtResult.setText("");
                        if (dotFlag) {//判断之前是否输入了点运算符
                          txtResult.setText("0." + e.getActionCommand());
                  Severity: Minor
                  Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.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 sampleWithNoRepeated has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public static <T> List<T> sampleWithNoRepeated(Map<T, Integer> rateMap, int count) {
                      List<T> result = new ArrayList<>();
                      for (int i = 0; i < count; i++) {
                        int total = 0;
                        for (Entry<T, Integer> entry : rateMap.entrySet()) {

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

                      @Override
                      public void run() {
                          while (hero.isAlive() && !exit) {
                              if (eventGroup.hasPressMoveEvent()) {
                  //                log.info("eventGroup={}", eventGroup);
                  Severity: Minor
                  Found in gui/src/main/java/com/github/kuangcp/tank/util/HeroKeyListener.java - About 1 hr to fix

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

                            try {
                                // 设置解密模式为AES的CBC模式
                                Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
                                SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
                                IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
                    Severity: Major
                    Found in class/src/main/java/security/aes/wx/WxMsgAESUtil.java and 1 other location - About 1 hr to fix
                    class/src/main/java/security/aes/wx/WXBizMsgCrypt.java on lines 144..159

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

                    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

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

                            try {
                                // 设置解密模式为AES的CBC模式
                                Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
                                SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
                                IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
                    Severity: Major
                    Found in class/src/main/java/security/aes/wx/WXBizMsgCrypt.java and 1 other location - About 1 hr to fix
                    class/src/main/java/security/aes/wx/WxMsgAESUtil.java on lines 65..80

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

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

                        private static void singleThreadMode() throws InterruptedException {
                            Thread normal = new Thread(() -> log.info("normal"));
                            normal.setName("normal");
                            normal.start();
                    
                    
                    Severity: Minor
                    Found in concurrency/src/main/java/thread/InterruptBizDemo.java - About 1 hr to fix

                      Method installGCMonitoring has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static void installGCMonitoring() {
                              //get all the GarbageCollectorMXBeans - there's one for each heap generation
                              //so probably two - the old generation and young generation
                              List<GarbageCollectorMXBean> gcbeans = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans();
                              //Install a notifcation handler for each bean
                      Severity: Minor
                      Found in class/src/main/java/jvm/gc/MxBeanCallback.java - About 1 hr to fix

                        Method action has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private void action() {
                                if (state == PersonState.FREEZE) {
                                    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

                        Severity
                        Category
                        Status
                        Source
                        Language