Skip to content

Commit

Permalink
Merge pull request #208 from JasonHHouse/improvement/sonarqube_code_c…
Browse files Browse the repository at this point in the history
…lean_up

Improvement/sonarqube code clean up
  • Loading branch information
JasonHHouse authored Jan 13, 2021
2 parents be0a0b0 + 58052a7 commit 5af57bb
Show file tree
Hide file tree
Showing 76 changed files with 473 additions and 272 deletions.
16 changes: 12 additions & 4 deletions Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.8</version>
<version>0.8.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>com.jasonhhouse</groupId>
<artifactId>Plex</artifactId>
<version>0.8.8</version>
<version>${gaps.version}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -46,7 +46,16 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>

<dependency>
Expand All @@ -57,7 +66,6 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.0</version>
</dependency>

<dependency>
Expand Down
14 changes: 8 additions & 6 deletions Core/src/main/java/com/jasonhhouse/gaps/PlexServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.jasonhhouse.plex.libs.PlexLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.LinkedHashSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class PlexServer {

@Schema(description = "Libraries that are of type movie in your Plex Server")
private final Set<PlexLibrary> plexLibraries;
private final List<PlexLibrary> plexLibraries;
@Schema(description = "Human readable way to identify your Plex Server")
private String friendlyName;
@Schema(description = "UID to identify the Plex Server")
Expand All @@ -35,7 +36,7 @@ public final class PlexServer {
private Integer port;

public PlexServer() {
plexLibraries = new LinkedHashSet<>();
plexLibraries = new ArrayList<>();
}

public PlexServer(String friendlyName, String machineIdentifier, String plexToken, String address, Integer port) {
Expand All @@ -44,7 +45,7 @@ public PlexServer(String friendlyName, String machineIdentifier, String plexToke
this.plexToken = plexToken;
this.address = address;
this.port = port;
plexLibraries = new LinkedHashSet<>();
plexLibraries = new ArrayList<>();
}

public String getFriendlyName() {
Expand All @@ -63,7 +64,8 @@ public void setMachineIdentifier(String machineIdentifier) {
this.machineIdentifier = machineIdentifier;
}

public Set<PlexLibrary> getPlexLibraries() {
public List<PlexLibrary> getPlexLibraries() {
Collections.sort(plexLibraries);
return plexLibraries;
}

Expand Down
6 changes: 3 additions & 3 deletions Core/src/main/java/com/jasonhhouse/gaps/Schedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public enum Schedule {
EVERY_TWO_WEEKS("Bi-weekly", "0 0 4 1,15 * ?", 3),
EVERY_MONTH("Monthly", "0 0 4 1 * ?", 4);

public static final String ID = "id";
public static final String MESSAGE = "message";
public static final String ENABLED = "enabled";
public static final String ID_LABEL = "id";
public static final String MESSAGE_LABEL = "message";
public static final String ENABLED_LABEL = "enabled";

@NotNull
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ protected ScheduleDeserializer(Class<?> vc) {
@Override
public Schedule deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
int id = node.get(Schedule.ID).numberValue().intValue();
Boolean enabled = node.get(Schedule.ENABLED).booleanValue();
int id = node.get(Schedule.ID_LABEL).numberValue().intValue();
Boolean enabled = node.get(Schedule.ENABLED_LABEL).booleanValue();
return Schedule.getSchedule(id).setEnabled(enabled);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.IOException;

public class ScheduleSerializer extends StdSerializer<Schedule> {

public ScheduleSerializer() {
this(null);
}
Expand All @@ -28,9 +29,9 @@ protected ScheduleSerializer(Class<Schedule> t) {
@Override
public void serialize(Schedule value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField(Schedule.ID, value.getId());
jsonGenerator.writeStringField(Schedule.MESSAGE, value.getMessage());
jsonGenerator.writeBooleanField("enabled", value.getEnabled());
jsonGenerator.writeNumberField(Schedule.ID_LABEL, value.getId());
jsonGenerator.writeStringField(Schedule.MESSAGE_LABEL, value.getMessage());
jsonGenerator.writeBooleanField(Schedule.ENABLED_LABEL, value.getEnabled());
jsonGenerator.writeEndObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class AbstractNotificationProperties implements NotificationProperties
@NotNull
protected final List<NotificationType> notificationTypes;

public AbstractNotificationProperties(@NotNull Boolean enabled, @NotNull List<NotificationType> notificationTypes) {
protected AbstractNotificationProperties(@NotNull Boolean enabled, @NotNull List<NotificationType> notificationTypes) {
this.enabled = enabled;
this.notificationTypes = notificationTypes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import com.jasonhhouse.gaps.PlexServer;
import com.jasonhhouse.gaps.Schedule;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class PushBulletProperties extends AbstractNotificationProperties {

@NotNull
@Schema(required = true, description = "The channel tag to receive messages")
private final String channel_tag;
private final String channelTag;

@NotNull
@Schema(required = true, description = "The API token connect to PushBullet")
Expand All @@ -36,10 +36,10 @@ public final class PushBulletProperties extends AbstractNotificationProperties {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public PushBulletProperties(@JsonProperty(value = "enabled", required = true) @NotNull Boolean enabled,
@JsonProperty(value = "notificationTypes", required = true) @NotNull List<NotificationType> notificationTypes,
@JsonProperty(value = "channel_tag") @Nullable String channel_tag,
@JsonProperty(value = "channel_tag") @Nullable String channelTag,
@JsonProperty(value = "accessToken") @Nullable String accessToken) {
super(enabled, notificationTypes);
this.channel_tag = channel_tag == null ? "" : channel_tag;
this.channelTag = channelTag == null ? "" : channelTag;
this.accessToken = accessToken == null ? "" : accessToken;
}

Expand All @@ -48,8 +48,8 @@ static PushBulletProperties getDefault() {
}

@NotNull
public String getChannel_tag() {
return channel_tag;
public String getChannelTag() {
return channelTag;
}

@NotNull
Expand All @@ -60,7 +60,7 @@ public String getAccessToken() {
@Override
public String toString() {
return "PushBulletProperties{" +
"channel_tag='" + channel_tag + '\'' +
"channelTag='" + channelTag + '\'' +
", accessToken='" + accessToken + '\'' +
", enabled=" + enabled +
", notificationTypes=" + notificationTypes +
Expand Down
4 changes: 2 additions & 2 deletions Core/src/main/java/com/jasonhhouse/gaps/service/IO.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.jasonhhouse.gaps.BasicMovie;
import com.jasonhhouse.gaps.Payload;
import com.jasonhhouse.gaps.properties.PlexProperties;
import java.io.File;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -51,7 +51,7 @@ public interface IO {
*/
void writeMovieIdsToFile(@NotNull Set<BasicMovie> everyBasicMovie);

void writeMovieIdsToFile(@NotNull Set<BasicMovie> everyBasicMovie, @NotNull File file);
void writeMovieIdsToFile(@NotNull Set<BasicMovie> everyBasicMovie, @NotNull Path path);

/**
* Prints out all recommended files to a text file called gaps_recommended_movies.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface PlexQuery {

void findAllMovieIds(@NotNull List<BasicMovie> basicMovies, @NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary);

@NotNull PlexServer getPlexServerFromMachineIdentifier(@NotNull PlexProperties plexProperties,@NotNull String machineIdentifier) throws IllegalArgumentException;
@NotNull PlexServer getPlexServerFromMachineIdentifier(@NotNull PlexProperties plexProperties,@NotNull String machineIdentifier);

@NotNull PlexLibrary getPlexLibraryFromKey(@NotNull PlexServer plexServer,@NotNull Integer key) throws IllegalArgumentException;
@NotNull PlexLibrary getPlexLibraryFromKey(@NotNull PlexServer plexServer,@NotNull Integer key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class DiscordPropertiesTest {
class DiscordPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class EmailPropertiesTest {
class EmailPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class GotifyPropertiesTest {
class GotifyPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class PushBulletPropertiesTest {
class PushBulletPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand All @@ -36,7 +36,7 @@ void addingEnabledAndNotificationTypes() throws JsonProcessingException {
PushBulletProperties pushBulletProperties = objectMapper.readValue("{\"enabled\":true,\"notificationTypes\":[]}", PushBulletProperties.class);
assertTrue(CollectionUtils.isEmpty(pushBulletProperties.getNotificationTypes()));
assertTrue(pushBulletProperties.getEnabled());
assertTrue(StringUtils.isEmpty(pushBulletProperties.getChannel_tag()));
assertTrue(StringUtils.isEmpty(pushBulletProperties.getChannelTag()));
assertTrue(StringUtils.isEmpty(pushBulletProperties.getAccessToken()));
}

Expand All @@ -45,7 +45,7 @@ void missingOneValue() throws JsonProcessingException {
PushBulletProperties pushBulletProperties = objectMapper.readValue("{\"enabled\":true,\"notificationTypes\":[],\"channel_tag\":\"123\"}", PushBulletProperties.class);
assertTrue(CollectionUtils.isEmpty(pushBulletProperties.getNotificationTypes()));
assertTrue(pushBulletProperties.getEnabled());
assertEquals("123", pushBulletProperties.getChannel_tag());
assertEquals("123", pushBulletProperties.getChannelTag());
assertTrue(StringUtils.isEmpty(pushBulletProperties.getAccessToken()));
}

Expand All @@ -54,7 +54,7 @@ void allValues() throws JsonProcessingException {
PushBulletProperties pushBulletProperties = objectMapper.readValue("{\"enabled\":true,\"notificationTypes\":[\"TEST\"],\"channel_tag\":\"123\",\"accessToken\":\"abc\"}", PushBulletProperties.class);
assertTrue(CollectionUtils.isNotEmpty(pushBulletProperties.getNotificationTypes()));
assertTrue(pushBulletProperties.getEnabled());
assertEquals("123", pushBulletProperties.getChannel_tag());
assertEquals("123", pushBulletProperties.getChannelTag());
assertEquals("abc", pushBulletProperties.getAccessToken());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class PushOverPropertiesTest {
class PushOverPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class SlackPropertiesTest {
class SlackPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TelegramPropertiesTest {
class TelegramPropertiesTest {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.8.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.8.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
4 changes: 1 addition & 3 deletions Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ LABEL maintainer="[email protected]"
LABEL name="Jason House"
LABEL github="https://github.com/JasonHHouse/Gaps"

RUN apt-get install -y openjdk-11-jre

EXPOSE 32400

ENV JAR_FILE gaps.jar
Expand All @@ -22,7 +20,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.8.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.raspbian
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM bellsoft/liberica-openjdk-alpine:11.0.9
FROM bellsoft/liberica-openjdk-alpine:11

LABEL maintainer="[email protected]"
LABEL name="Jason House"
Expand All @@ -20,7 +20,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.8.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.riscv64
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.8.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion GapsAsJar/gaps.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ RMDIR /r $INSTDIR
SectionEnd

# name the installer
OutFile "gaps-0.8.8-installer.exe"
OutFile "gaps-0.8.9-installer.exe"
Loading

0 comments on commit 5af57bb

Please sign in to comment.