Kuangcp/JavaBase

View on GitHub

Showing 217 of 353 total issues

Method channelRead0 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
        Channel ch = ctx.channel();
        if (!shaker.isHandshakeComplete()) {
            try {

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

      Method paint has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void paint(Graphics graphics) {
              super.paint(graphics);
      
              //draw border

        Method openFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private void openFile() {
            //推荐JFileChooser 组件
            JFileChooser jc = new JFileChooser();
            //设置名字
            jc.setDialogTitle("Please select file...");

          Method execute has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              public Result execute(Param param, long timeout, TimeUnit timeUnit) {
                  final LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(1000);
                  final Result result = Result.builder().dataList(Collections.synchronizedList(new ArrayList<>()))
                          .build();
          Severity: Minor
          Found in concurrency/src/main/java/situation/timoutpool/CreateNewPool.java - About 1 hr to fix

            Method quickSort has 28 lines of code (exceeds 25 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 1 hr to fix

              Method insertWheel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private boolean insertWheel(String id, Duration delay) {
                      long days = delay.toDays();
                      if (days > 30) {
                          log.warn("out of timeWheel max delay bound");
                          return false;

                Method showRows has 28 lines of code (exceeds 25 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(" + ");

                  Method decrypt has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      String decrypt(String text) throws AesException {
                          byte[] original;
                          try {
                              // 设置解密模式为AES的CBC模式
                              Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
                  Severity: Minor
                  Found in class/src/main/java/security/aes/wx/WXBizMsgCrypt.java - About 1 hr to fix

                    Method init has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public void init() {
                        try {
                          keyIn = new BufferedReader(new InputStreamReader(System.in));
                          socket = new Socket("127.0.0.1", ChatProtocol.SERVER_PORT);
                          ps = new PrintStream(socket.getOutputStream());
                    Severity: Minor
                    Found in network/src/main/java/com/github/kuangcp/bio/onechatone/Client.java - About 1 hr to fix

                      Method setSeed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public final synchronized void setSeed(int[] buf) {
                          int length = buf.length;
                      
                          if (length == 0) {
                            throw new IllegalArgumentException("Seed buffer may not be empty");

                      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 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          @Override
                          public void sortData(int[] data, int low, int high) {
                            if (low >= high) {
                              return;
                            }
                      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 removeAndAdd has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private void removeAndAdd(ChronoUnit unit, int index) {
                              LinkedList<TaskNode>[] lists = wheels.get(unit);
                              LinkedList<TaskNode> list = lists[index];
                              if (Objects.nonNull(list) && !list.isEmpty()) {
                                  List<TaskNode> nodes = list.toList();

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

                          @Override
                          public void actionPerformed(ActionEvent event) {
                              if (PlayStageMgr.stageNoneStart()) {
                                  return;
                              }
                      Severity: Minor
                      Found in gui/src/main/java/com/github/kuangcp/tank/v3/SettingFrame.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 btnEqualActionPerformed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        void btnEqualActionPerformed() {
                          if (!calculateFlag) { //未曾按下等于运算符
                            behind = txtResult.getText();
                          } else {
                            front = result;
                      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 otherThreadWithOOM has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public void otherThreadWithOOM() throws Exception {
                              // 如果将该集合定义在这里 就会被所有线程共享 被引用数会多, 不容易回收, 就容易引起全面的OOM 导致进程退出
                      //    List<byte[]> data = new ArrayList<>();
                      
                              Thread allocateMemory = new Thread(() -> {
                      Severity: Minor
                      Found in class/src/main/java/jvm/oom/HeapOOM.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 shotEnemy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public void shotEnemy() {
                              final long nowMs = System.currentTimeMillis();
                              if (lastShotMs != 0 && nowMs - lastShotMs < shotCDMs) {
                                  return;
                              }
                      Severity: Minor
                      Found in gui/src/main/java/com/github/kuangcp/tank/domain/Hero.java - About 1 hr to fix

                        Method setSeed has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          public final synchronized void setSeed(int[] buf) {
                            int length = buf.length;
                        
                            if (length == 0) {
                              throw new IllegalArgumentException("Seed buffer may not be empty");

                          Method main has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static void main(String[] args) {
                                  DisposableServer server = HttpServer.create()
                                          .route(routes -> routes
                                                  .get("/hello",
                                                          (request, response) -> {
                          Severity: Minor
                          Found in netty/src/main/java/reactor/http/FirstHttpServer.java - About 1 hr to fix

                            Method init has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private void init() {
                                    //添加求解式的数据
                                    String max = config.getString("Max");
                                    String[] temp = max.split(",");
                                    for (String data : temp) {
                              Severity
                              Category
                              Status
                              Source
                              Language