Kuangcp/JavaBase

View on GitHub

Showing 226 of 360 total issues

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

    public void run() {
        while (true) {
            try {
                log.info("#####  Waiting for client on port " + serverSocket.getLocalPort() + "...");
                Socket server = serverSocket.accept();

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 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 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 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) {

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

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

              private void handleInput(Selector selector, SelectionKey key) throws IOException {
                if (key.isValid()) {
                  if (key.isAcceptable()) {
                    // Accept the new connection
                    ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
            Severity: Minor
            Found in network/src/main/java/com/github/kuangcp/nio/EchoNIOServer.java - About 1 hr to fix

              Method initPool has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                protected void initPool() {
                  if (Objects.isNull(property) || !property.isAbleToInit()) {
                    return;
                  }
              
              
              Severity: Minor
              Found in concurrency/src/main/java/redis/migration/RedisPools.java - About 1 hr to fix

                Method finalMoveAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private void finalMoveAction() {
                        final boolean sameDirect = actionContext.getSameDirectCounter() > actionContext.getCurRoundStep();
                        final boolean ablePassHero = PlayStageMgr.ablePassByHero(this);
                        final boolean ablePassHinder = PlayStageMgr.ablePassByHinder(this);
                
                
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/tank/domain/EnemyTank.java - About 1 hr to fix

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

                      public void paint(Graphics g) {
                          super.paint(g);
                  
                          final StageBorder border = RoundMapMgr.instance.border;
                          g.fillRect(0, 0, border.getMaxX() + border.getMinX(), border.getMaxY() + border.getMinY());
                  Severity: Minor
                  Found in gui/src/main/java/com/github/kuangcp/tank/v2/MainPanelV2.java - About 1 hr to fix

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

                        public static void main(String[] args) {
                            ServerSocket serverSocket = null;
                            Socket socket = null;
                            OutputStream os = null;
                            InputStream is = null;
                    Severity: Minor
                    Found in network/src/main/java/com/github/kuangcp/port/MulSocketServer.java - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                                          if (('a' <= exChar[i] && exChar[i] <= 'z') || ('A' <= exChar[i] && exChar[i] <= 'Z') || exChar[i] == '_' || ('0' <= exChar[i] && exChar[i] <= '9')) {
                                              sb.append('.');
                                              i = getI(exChar, i, sb);
                                          } else {
                                              throw new RuntimeException("词法错误!");

                        Method paint has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public void paint(Graphics g) {
                                super.paint(g);
                        
                                final StageBorder border = RoundMapMgr.instance.border;
                                g.fillRect(0, 0, border.getMaxX() + border.getMinX(), border.getMaxY() + border.getMinY());
                        Severity: Minor
                        Found in gui/src/main/java/com/github/kuangcp/tank/v2/MainPanelV2.java - About 55 mins 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 printWheel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public void printWheel() {
                                log.info("sec:{} min:{} hour:{}", this.currentSecond.get(), this.currentMinute.get(),
                                        this.currentHour.get());
                                for (ChronoUnit unit : wheels.keySet()) {
                                    LinkedList[] lists = wheels.get(unit);
                        Severity: Minor
                        Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.java - About 55 mins 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 checkBong has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private void checkBong(Tank tank, Bullet bullet) {
                                if (!bullet.alive || !tank.isAlive()) {
                                    return;
                                }
                        
                        
                        Severity: Minor
                        Found in gui/src/main/java/com/github/kuangcp/tank/mgr/BombMgr.java - About 55 mins 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 showResult has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private static void showResult(int maxRow, int maxCol, char[][] print) {
                                System.out.printf("最短路径的长度 %d\n\n", minSize);
                                System.out.print("最短的路径:");
                                for (int k = 0; k < minSize; k++) {
                                    System.out.printf("(%d,%d)  ", path[k].row, path[k].col);

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

                            @Override
                            public void keyPressed(KeyEvent e) {
                                // 启动关闭流程
                                if (e.getKeyCode() == KeyEvent.VK_Q && HoldingKeyEventMgr.instance.isCtrl()) {
                                    System.exit(0);
                        Severity: Minor
                        Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 55 mins 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 originRun has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private void originRun() {
                                do {
                                    // 每个子弹发射的延迟运动的时间
                                    TankTool.yieldMsTime(55);
                        
                        
                        Severity: Minor
                        Found in gui/src/main/java/com/github/kuangcp/tank/domain/Bullet.java - About 55 mins 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 readContent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private void readContent(Selector selector, SelectionKey sk) throws IOException {
                            SocketChannel sc = (SocketChannel) sk.channel();
                            ByteBuffer buff = ByteBuffer.allocate(1024);
                        
                            StringBuilder content = new StringBuilder();
                        Severity: Minor
                        Found in network/src/main/java/com/github/kuangcp/nio/NIOServer.java - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private void start() throws Exception {
                            Selector selector = Selector.open();
                        
                            //通过OPEN方法来打开一个未绑定的ServerSocketChannel 实例
                            ServerSocketChannel server = ServerSocketChannel.open();
                        Severity: Minor
                        Found in network/src/main/java/com/github/kuangcp/nio/NIOServer.java - About 55 mins 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