Kuangcp/JavaBase

View on GitHub

Showing 226 of 360 total issues

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

          public static void main(String[] args) throws Exception {
              URI uri = new URI(URL);
              String scheme = uri.getScheme() == null ? "ws" : uri.getScheme();
              final String host = uri.getHost() == null ? "127.0.0.1" : uri.getHost();
              final int port;
      Severity: Minor
      Found in netty/src/main/java/netty/websocket/client/Client.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 main has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public static void main(String[] args) throws Exception {
                URI uri = new URI(URL);
                String scheme = uri.getScheme() == null ? "ws" : uri.getScheme();
                final String host = uri.getHost() == null ? "127.0.0.1" : uri.getHost();
                final int port;
        Severity: Minor
        Found in netty/src/main/java/netty/websocket/client/Client.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

          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 singleThreadMode has a Cognitive Complexity of 13 (exceeds 5 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

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

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

                  private int parseArgs(String[] args) throws UnknownHostException {
                      int base;
                      label:
                      for (base = 0; base < args.length; base++) {
                          switch (args[base]) {

              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 handleInput has a Cognitive Complexity of 13 (exceeds 5 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

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

                  public void run(){
                      try{
                          br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                          ps = new PrintStream(socket.getOutputStream());
                          String line = null;

                Method readDataBase has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public void readDataBase() {
                        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 1 hr to fix

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

                    Method pushTimeWheel has 37 lines of code (exceeds 25 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);

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

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

                          public static void main(String[] a) {
                            final CountDownLatch firstLatch = new CountDownLatch(1);
                            final CountDownLatch secondLatch = new CountDownLatch(1);
                            // 使用不可变对象
                            final BuildFactory.Builder builder = new BuildFactory.Builder();

                          Method initLogicButton has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private void initLogicButton() {
                              txtResult.setEnabled(false);
                              txtResult.setEditable(false);
                              txtResult.setHorizontalAlignment(SwingConstants.RIGHT);
                              txtResult.setBounds(new Rectangle(33, 19, 310, 34));
                          Severity: Minor
                          Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.java - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language