Skip to content

Commit

Permalink
Fixes more Sonar complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
fathzer committed Nov 26, 2024
1 parent a606e6d commit 2af1de0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 36 deletions.
25 changes: 0 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.1</version>
<configuration>
<source>${maven.compiler.release}</source>
<docencoding>UTF-8</docencoding>
<overview>${basedir}/overview.html</overview>
<header>${project.version}</header>
<bottom>${project.version}</bottom>
<links>
<link>https://docs.oracle.com/javase/17/docs/api/</link>
</links>
</configuration>
<executions>
<execution>
<id>javadoc_generation</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>-->
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.function.Consumer;

import com.fathzer.games.util.exec.CustomThreadFactory;
import com.fathzer.jchess.uci.UCI.ThrowingRunnable;

class BackgroundTaskManager implements AutoCloseable {
static class Task {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fathzer/jchess/uci/GoReply.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public Optional<String> getMainInfoString() {
return bestMove==null ? Optional.empty() : getInfoString(0);
}

/** Gets the uci info line to return just before sending the reply.
/** Gets a uci info line to return before sending the reply.
* @param index The move index (0 for the best move or the index or the extra moves passed to {@code Info#setExtraMoves(List)} +1
* @return The line or an empty optional if no information is available
*/
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/fathzer/jchess/uci/ThrowingRunnable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.fathzer.jchess.uci;

@FunctionalInterface
/** A runnable that can throw an exception.
*/
public interface ThrowingRunnable {
void run() throws Exception;
}
14 changes: 5 additions & 9 deletions src/main/java/com/fathzer/jchess/uci/UCI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.stream.Collectors;

import com.fathzer.jchess.uci.BackgroundTaskManager.Task;
import com.fathzer.jchess.uci.GoReply.Info;
import com.fathzer.jchess.uci.option.IntegerSpinOption;
import com.fathzer.jchess.uci.option.Option;
import com.fathzer.jchess.uci.parameters.GoParameters;
Expand All @@ -38,13 +39,6 @@
public class UCI implements Runnable, AutoCloseable {
public static final String INIT_COMMANDS_PROPERTY_FILE = "uciInitCommands";

@FunctionalInterface
/** A runnable that can throw an exception.
*/
public static interface ThrowingRunnable {
void run() throws Exception;
}

private static final BufferedReader IN = new BufferedReader(new InputStreamReader(System.in));
private static final String MOVES = "moves";
private static final String ENGINE_CMD = "engine";
Expand Down Expand Up @@ -227,8 +221,10 @@ private void processGo(final StoppableTask<GoReply> task) throws Exception {
final Optional<String> mainInfo = goReply.getMainInfoString();
if (mainInfo.isPresent()) {
this.out(mainInfo.get());
for (int i = 1; i <= goReply.getInfo().get().getExtraMoves().size(); i++) {
this.out(goReply.getInfoString(i).get());
final Optional<Info> info = goReply.getInfo();
final int nb = info.isPresent() ? info.get().getExtraMoves().size() : 0;
for (int i = 1; i <= nb; i++) {
goReply.getInfoString(i).ifPresent(this::out);
}
}
out(goReply.toString());
Expand Down

0 comments on commit 2af1de0

Please sign in to comment.