Kuangcp/JavaBase

View on GitHub

Showing 226 of 360 total issues

Avoid too many return statements within this method.
Open

            return 10000;
Severity: Major
Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return 0xf4240;
    Severity: Major
    Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.java - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return 100;
        Severity: Major
        Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return count != 2 || color != myColor || block != 1 ? 0 : 1;
          Severity: Major
          Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return insertWheel(ChronoUnit.SECONDS, this.currentSecond.get() + 1, node);
            Severity: Major
            Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return 0x186a0;
              Severity: Major
              Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 30 mins to fix

                Method willInfected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public void willInfected() {
                        if (this.isInfected()) {
                            return;
                        }
                
                
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/virusbroadcast/domain/Person.java - About 25 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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public void run() {
                        File soundFile = new File(filename);
                
                        AudioInputStream audioInputStream;
                        try {
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/tank/util/Audio.java - About 25 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 sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  public int[] sort(int[] data) {
                    int[] result = Arrays.copyOf(data, data.length);
                
                    for (int i = 1; i < result.length; i++) {
                      //用来冒泡的语句,0到已排序的部分
                Severity: Minor
                Found in algorithms/src/main/java/com/github/kuangcp/sort/Bubble.java - About 25 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 sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  public int[] sort(int[] data) {
                    int[] result = Arrays.copyOf(data, data.length);
                
                    for (int i = 0; i < result.length - 1; i++) {
                      //这个循环就是把较小数堆叠在数组头,依次与后面比较再交换
                Severity: Minor
                Found in algorithms/src/main/java/com/github/kuangcp/sort/Select.java - About 25 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 initBigInteger has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  private boolean initBigInteger(String target, MythBaseStack<Integer> stack) {
                    String regex = "^[0-9]+$";
                    boolean oneResult = Pattern.matches(regex, target);
                    if (!oneResult) {
                      log.error("there are not integer: one={}", target);

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

                  void transferAllKey() throws InterruptedException {
                    boolean init = initRedisPool();
                    if (!init) {
                      return;
                    }
                Severity: Minor
                Found in concurrency/src/main/java/redis/migration/Main.java - About 25 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 mouseClicked has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public void mouseClicked(MouseEvent e) {
                        if (playerPlay) {
                            int x = getGridXY(e.getX());
                            int y = getGridXY(e.getY());
                            if (hasChess(x, y))
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/gomoku/ChessBoard.java - About 25 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 setSeed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  public final synchronized void setSeed(long seed) {
                    if (compact) {
                      setSeed((int) seed);
                    } else {
                      // Annoying runtime check for initialisation of internal data
                Severity: Minor
                Found in algorithms/src/main/java/com/github/kuangcp/random/MT19937Random.java - About 25 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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    @Override
                    public void run() {
                        int maxFPS = 60;
                        long fpsTime = (long) ((1000.0 / maxFPS) * 1_000_000);
                
                
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/tank/v2/MainPanelV2.java - About 25 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 filterClassName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  private boolean filterClassName(String className) {
                    if (!className.endsWith(suffix)) {
                      return false;
                    }
                
                
                Severity: Minor
                Found in class/src/main/java/com/github/kuangcp/read/ClassScanner.java - About 25 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 getPackageAllClasses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  public Set<Class<?>> getPackageAllClasses(String basePackage, boolean recursive) {
                    Set<Class<?>> classes = new LinkedHashSet<>();
                    String packageName = basePackage;
                    if (basePackage.endsWith(".")) {
                      packageName = basePackage.substring(0, basePackage.length() - 1);
                Severity: Minor
                Found in class/src/main/java/com/github/kuangcp/read/ClassScanner.java - About 25 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 readAndSend has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  private void readAndSend() {
                    try {
                      String line;
                      while ((line = keyIn.readLine()) != null) {
                        //如果消息中含 : 并且是//用户名 开头,则是判断为私聊
                Severity: Minor
                Found in network/src/main/java/com/github/kuangcp/bio/onechatone/Client.java - About 25 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 isNeedContinue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private boolean isNeedContinue(List<Fraction> list) {
                        boolean flag = false;
                        for (Fraction b : list) {
                            if (b.isPositive()) {
                                flag = true;

                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