Skip to content

Commit 762828d

Browse files
committed
Minor clean up (improve Codacy score)
1 parent eaa2143 commit 762828d

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/core/ZeroconfServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private ZeroconfServer(Session.Inner inner, Configuration conf) throws IOExcepti
152152
@NotNull
153153
public static String getUsefulHostname() throws UnknownHostException {
154154
String host = InetAddress.getLocalHost().getHostName();
155-
if (host.equals("localhost")) {
155+
if (Objects.equals(host, "localhost")) {
156156
host = Base64.getEncoder().encodeToString(BigInteger.valueOf(ThreadLocalRandom.current().nextLong()).toByteArray()) + ".local";
157157
LOGGER.warn("Hostname cannot be `localhost`, temporary hostname: " + host);
158158
return host;

core/src/main/java/xyz/gianlu/librespot/mercury/MercuryRequests.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.google.gson.JsonObject;
55
import com.spotify.metadata.proto.Metadata;
66
import com.spotify.playlist4.proto.Playlist4ApiProto;
7-
import org.jetbrains.annotations.Contract;
87
import org.jetbrains.annotations.NotNull;
98
import org.jetbrains.annotations.Nullable;
109
import spotify.player.proto.ContextPageOuterClass;
@@ -99,14 +98,7 @@ public static JsonMercuryRequest<KeymasterToken> requestToken(@NotNull String de
9998
@NotNull
10099
private static String getAsString(@NotNull JsonObject obj, @NotNull String key) {
101100
JsonElement elm = obj.get(key);
102-
if (elm == null) throw new NullPointerException("Unexpected null value for " + key);
103-
else return elm.getAsString();
104-
}
105-
106-
@Contract("_, _, !null -> !null")
107-
private static String getAsString(@NotNull JsonObject obj, @NotNull String key, @Nullable String fallback) {
108-
JsonElement elm = obj.get(key);
109-
if (elm == null) return fallback;
101+
if (elm == null) throw new IllegalArgumentException("Unexpected null value for " + key);
110102
else return elm.getAsString();
111103
}
112104

core/src/main/java/xyz/gianlu/librespot/player/feeders/storage/AudioFileStreaming.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public void writeChunk(byte[] buffer, int chunkIndex, boolean cached) throws IOE
148148

149149
@Override
150150
public void writeHeader(byte id, byte[] bytes, boolean cached) {
151+
// Not interested
151152
}
152153

153154
@Override

0 commit comments

Comments
 (0)