Kuangcp/JavaBase

View on GitHub

Showing 349 of 349 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    try (BufferedWriter bw = new BufferedWriter(new FileWriter(currentPath))) {
      bw.write(Note.textArea.getText());
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
gui/src/main/java/com/github/kuangcp/notepad/handler/FileHandler.java on lines 117..121

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            while (contains(x - 1, y + 1, color) == 1) {
                x--;
                y++;
                count++;
            }
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java and 1 other location - About 30 mins to fix
gui/src/main/java/com/github/kuangcp/gomoku/AI.java on lines 161..165

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            while (contains(x - 1, y - 1, color) == 1) {
                x--;
                y--;
                count++;
            }
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java and 1 other location - About 30 mins to fix
gui/src/main/java/com/github/kuangcp/gomoku/AI.java on lines 183..187

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  public static DoubleCheck getInstance() {
    if (singleton == null) {
      synchronized (DoubleCheck.class) {
        // 因为 new 这个操作是分为三步
        // 1.分配内存空间,
pattern/src/main/java/com/github/kuangcp/singleton/DoubleCheckWithVolatile.java on lines 15..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 41.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  public static DoubleCheckWithVolatile getInstance() {
    if (singleton == null) {
      synchronized (DoubleCheckWithVolatile.class) {
        if (singleton == null) {
          singleton = new DoubleCheckWithVolatile();
pattern/src/main/java/com/github/kuangcp/singleton/DoubleCheck.java on lines 22..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 41.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Avoid too many return statements within this method.
    Open

                return 10;
    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 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 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 true;
            Severity: Major
            Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 30 mins to fix

              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 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 1000;
                    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 0;

                        Avoid too many return statements within this method.
                        Open

                                    return insertWheel(ChronoUnit.SECONDS, this.currentSecond.get() + seconds, 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 0;

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                                if (parts.length == 2) {
                                                    proxyHost = parts[0];
                                                    proxyPort = Integer.parseInt(parts[1]);
                                                }
                            network/src/main/java/com/github/kuangcp/app/ftp/FTPClientExample.java on lines 128..131

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 40.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    if (parts.length == 2) {
                                        server = parts[0];
                                        port = Integer.parseInt(parts[1]);
                                    }
                            network/src/main/java/com/github/kuangcp/app/ftp/FTPClientExample.java on lines 490..493

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 40.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Severity
                            Category
                            Status
                            Source
                            Language