Skip to content

Commit

Permalink
refactor: Common static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider and TeamModerne committed Jan 16, 2024
1 parent b13bafa commit 93e9cca
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/polyglot/OmniParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public Builder exclusionMatchers(Collection<PathMatcher> exclusions) {

public Builder exclusionMatchers(Path basePath, Iterable<String> exclusions) {
return exclusionMatchers(StreamSupport.stream(exclusions.spliterator(), false)
.map((o) -> basePath.getFileSystem().getPathMatcher("glob:" + o))
.map(o -> basePath.getFileSystem().getPathMatcher("glob:" + o))
.collect(Collectors.toList()));
}

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/openrewrite/polyglot/RemoteException.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,19 @@ public static RemoteException decode(String encoded) {
String[] lines = encoded.split("\n");
return new RemoteException(
new String(base64.decode(lines[0]), UTF_8),
lines[1].equals("null") ? null : new String(base64.decode(lines[1]), UTF_8),
lines[2].equals("null") ? new String[0] : stream(lines[2].split(",")).map(s -> new String(base64.decode(s), UTF_8)).toArray(String[]::new)
"null".equals(lines[1]) ? null : new String(base64.decode(lines[1]), UTF_8),
"null".equals(lines[2]) ? new String[0] : stream(lines[2].split(",")).map(s -> new String(base64.decode(s), UTF_8)).toArray(String[]::new)
);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RemoteException that = (RemoteException) o;
return Objects.equals(sanitizedStackTrace, that.sanitizedStackTrace) && Objects.equals(fixSuggestions, that.fixSuggestions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class RemoteProgressBarReceiver implements ProgressBar {

private final ProgressBar delegate;
private final DatagramSocket socket;
private volatile boolean closed = false;
private volatile boolean closed;
private final AtomicReference<String> thrown = new AtomicReference<>();

public RemoteProgressBarReceiver(ProgressBar delegate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public RemoteProgressBarSender(@Nullable InetAddress address, int port) {
this.port = port;
this.address = address == null ? InetAddress.getByName(localhost) : address;
} catch (UnknownHostException | SocketException e) {
if (localhost.equals("host.docker.internal")) {
if ("host.docker.internal".equals(localhost)) {
try {
this.address = InetAddress.getByName("localhost");
this.port = port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.function.Consumer;
import java.util.stream.Stream;

public class SourceFileStream implements Stream<SourceFile> {
public final class SourceFileStream implements Stream<SourceFile> {

@Delegate
private final Stream<SourceFile> delegate;
Expand Down

0 comments on commit 93e9cca

Please sign in to comment.