Kuangcp/JavaBase

View on GitHub

Showing 221 of 349 total issues

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

    public void drawBomb(Graphics g, JPanel panel) {
        for (int i = 0; i < bombs.size(); i++) {
            //取出炸弹
            Bomb b = bombs.get(i);
            if (b.life > 10) {
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/tank/mgr/BombMgr.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

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

    public static void main(String[] args) throws InterruptedException {
        log.info("start");
        Thread sleep = new Thread(() -> {
            while (true) {
                try {
Severity: Minor
Found in concurrency/src/main/java/thread/InterruptHandleDemo.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

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

    public static void main(String[] s) {
        String[] args = {"localhost", "10000"};
        String serverName = args[0];
        int port = Integer.parseInt(args[1]);

Severity: Minor
Found in network/src/main/java/com/github/kuangcp/runable/GreetingClient.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

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

    public void createArrayRecovery() {
        try {
            List<byte[]> data = new ArrayList<>();
            while (true) {
                try {
Severity: Minor
Found in class/src/main/java/jvm/oom/HeapOOM.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

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

  public void init() {
    try {
      keyIn = new BufferedReader(new InputStreamReader(System.in));
      socket = new Socket("127.0.0.1", ChatProtocol.SERVER_PORT);
      ps = new PrintStream(socket.getOutputStream());
Severity: Minor
Found in network/src/main/java/com/github/kuangcp/bio/onechatone/Client.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

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

    public void run() {
      try {
        while (!stop) {
          // 如果不设置超时时间会一直阻塞等待,导致客户端无法退出
          selector.select(5000);
Severity: Minor
Found in network/src/main/java/com/github/kuangcp/nio/NIOClient.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

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

    private void display(String title, boolean titleTurn, List list, boolean turn) {
        if (titleTurn) {
            System.out.println(title);
        } else {
            System.out.print(title + " :    ");

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

  public static <T> List<T> sampleWithNoRepeatedWithPutBack(Map<T, Integer> rateMap, int count) {
    List<T> result = new ArrayList<>();
    int total = 0;
    for (Entry<T, Integer> entry : rateMap.entrySet()) {
      total += entry.getValue();
Severity: Minor
Found in class/src/main/java/com/github/kuangcp/generic/sample/SampleUtil.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

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

  long martingale(long principal, int count) {
    if (count < 0) {
      return principal;
    }
    long origin = principal;
Severity: Minor
Found in question/src/main/java/com/github/kuangcp/math/Martingale.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

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;
                        Severity
                        Category
                        Status
                        Source
                        Language