Kuangcp/JavaBase

View on GitHub

Showing 226 of 360 total issues

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

    public void mouseMoved(MouseEvent e) {
        int x = getGridXY(e.getX());
        int y = getGridXY(e.getY());
        x = x >= 0 ? x : 0;
        x = x <= 14 ? x : 14;
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/gomoku/ChessBoard.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 found has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  private static void found(int[] arr, int left, int right, int data) {

    int mid = (left + right) / 2;
    if (arr[mid] == data) {
      index = mid;
Severity: Minor
Found in algorithms/src/main/java/com/github/kuangcp/found/BinarySearch.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  public void add(String str) {
    for (Function<String, Integer> function : functions) {
      Integer hash = function.apply(str);
      int index = hash / LEN_OF_BYTE;
      if (log.isDebugEnabled()) {

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

    @Override
    public void actionPerformed(ActionEvent ae) {
        if (ae.getActionCommand().equals(ButtonCommand.START)) {
            this.startNewStage();
        }
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/tank/panel/StageActionPanel.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 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 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 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 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

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

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