Kuangcp/JavaBase

View on GitHub

Showing 226 of 360 total issues

Method generateKey has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  public String generateKey(BigInteger privKey, BigInteger pubKey, int licenseType, int productId,
      int minorVersion, int majorVersion, String userName) {
Severity: Major
Found in question/src/main/java/com/github/kuangcp/key/CreateKey.java - About 50 mins to fix

    Method ablePassByHinder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static boolean ablePassByHinder(Tank t) {
            if (Objects.isNull(instance) || Objects.isNull(instance.hero) || !instance.hero.isAlive()) {
                return true;
            }
    
    
    Severity: Minor
    Found in gui/src/main/java/com/github/kuangcp/tank/v3/PlayStageMgr.java - About 45 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 findBestPosition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private void findBestPosition() {
            int tempScore = 0;
            bestX = effectiveX1;
            bestY = effectiveY1;
            for (int x = effectiveX1; x <= effectiveX2; x++) {
    Severity: Minor
    Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 45 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 consumerScheduler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private static void consumerScheduler() throws InterruptedException {
            Thread producer = new Thread(() -> {
                AtomicInteger count = new AtomicInteger();
                while (true) {
                    try {
    Severity: Minor
    Found in concurrency/src/main/java/thread/InterruptBizDemo.java - About 45 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 initPool has a Cognitive Complexity of 8 (exceeds 5 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 45 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

    Avoid deeply nested control flow statements.
    Open

                if (temps.get(k) != null) {
                  dat.add(temps.get(k));
                }
    Severity: Major
    Found in algorithms/src/main/java/com/github/kuangcp/sort/Shell.java - About 45 mins to fix

      Method sort has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        public int[] sort(int[] data) {
          int[] result = Arrays.copyOf(data, data.length);
          List<Integer> temp = Arrays.stream(data).boxed().collect(Collectors.toList());
      
          // 0 -> []. 1 -> [], ... 9 -> []
      Severity: Minor
      Found in algorithms/src/main/java/com/github/kuangcp/sort/Radix.java - About 45 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 getI has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private static int getI(char[] exChar, int i, StringBuilder sb) {
              while (('a' <= exChar[i] && exChar[i] <= 'z') || ('A' <= exChar[i] && exChar[i] <= 'Z') || exChar[i] == '_' || ('0' <= exChar[i] && exChar[i] <= '9')) {
                  if (i == exChar.length - 1) {
                      sb.append(exChar[i]);
                      break;

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

        private void scanEntry(String packagePath, Set<Class<?>> classes, Enumeration entries) {
          if (!entries.hasMoreElements()) {
            return;
          }
      
      
      Severity: Minor
      Found in class/src/main/java/com/github/kuangcp/read/ClassScanner.java - About 45 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 generateKeyBytes has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        private byte[] generateKeyBytes(int licenseType, int productId,
            int minorVersion, int majorVersion,
            String userName, int customerId) {
      Severity: Minor
      Found in question/src/main/java/com/github/kuangcp/key/CreateKey.java - About 45 mins to fix

        Method minAndMax has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          public static <T extends Comparable<T>> Pair<T> minAndMax(T[] list) {
            if (list == null || list.length == 0) {
              return null;
            }
        
        
        Severity: Minor
        Found in class/src/main/java/com/github/kuangcp/generic/simple/Pair.java - About 45 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

        Consider simplifying this complex logical expression.
        Open

                    else if (listFiles || mlsd || mdtm || mlst || listNames || size) {
                        if (mlsd) {
                            for (final FTPFile f : ftp.mlistDir(remote)) {
                                System.out.println(f.getRawListing());
                                System.out.println(f.toFormattedString(displayTimeZoneId));
        Severity: Major
        Found in network/src/main/java/com/github/kuangcp/app/ftp/FTPClientExample.java - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                      if (exChar[i] == '+' || exChar[i] == '-' || exChar[i] == '*' || exChar[i] == '/' || exChar[i] == '(' || exChar[i] == ')') {
                          StringBuilder sb = new StringBuilder();
                          sb.append(exChar[i]);
                          switch (exChar[i]) {
                              case '+':

            Method createB has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public void createB(List<Brick> bricks, int startX, int startY, int endX, int endY) {
            Severity: Minor
            Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 35 mins to fix

              Method clientChannel has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private static void clientChannel(WebSocketClientHandler handler, EventLoopGroup group, SslContext sslCtx,
                                                    String host, int port) throws InterruptedException {
              Severity: Minor
              Found in netty/src/main/java/netty/websocket/client/Client.java - About 35 mins to fix

                Method createI has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public void createI(List<Iron> irons, int startX, int startY, int endX, int endY) {
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 35 mins to fix

                  Method decryptFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static void decryptFile(String algorithm, SecretKey key, IvParameterSpec iv,
                                                     File encryptedFile, File decryptedFile) throws IOException, NoSuchPaddingException,
                  Severity: Minor
                  Found in class/src/main/java/security/aes/AESUtil.java - About 35 mins to fix

                    Method encryptFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public static void encryptFile(String algorithm, SecretKey key, IvParameterSpec iv,
                                                       File inputFile, File outputFile) throws IOException, NoSuchPaddingException,
                    Severity: Minor
                    Found in class/src/main/java/security/aes/AESUtil.java - About 35 mins to fix

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

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

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

                          @Override
                          public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
                              Channel ch = ctx.channel();
                              if (!shaker.isHandshakeComplete()) {
                                  try {
                      Severity: Minor
                      Found in netty/src/main/java/netty/websocket/client/WebSocketClientHandler.java - About 35 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