Skip to content

Commit

Permalink
Merge pull request tech-by-design#276 from razakpm/main
Browse files Browse the repository at this point in the history
chore: resolve spotbug, pmd and checkstyle issues
  • Loading branch information
ratheesh-kr authored Aug 7, 2024
2 parents abf5c6b + 57961ae commit d139961
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 24 deletions.
11 changes: 11 additions & 0 deletions hub-prime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>6.36.0</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.8.6</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class InteractionsFilter extends OncePerRequestFilter {

// TODO: figure out why this is not being read from application.yml (NULL is
// being called, though)
@SuppressWarnings("PMD.UnusedPrivateMethod")
@Value("${org.techbd.service.http.interactions.persist.db.uri-matcher.regex:#{null}}")
private void setPersistInDbMatchers(final List<Object> regexAndMethods) {
LOG.info("setPersistInDbMatchers %s".formatted(regexAndMethods == null ? "NULL" : regexAndMethods.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class ExpectController {

private static final Logger LOG = LoggerFactory.getLogger(ExpectController.class.getName());

public ExpectController(final Environment environment, final AppConfig appConfig) {
public ExpectController(@SuppressWarnings("PMD.UnusedFormalParameter") final Environment environment,
@SuppressWarnings("PMD.UnusedFormalParameter") final AppConfig appConfig) {
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public class FhirController {
private final AppConfig appConfig;
private final UdiPrimeJpaConfig udiPrimeJpaConfig;

public FhirController(final Environment environment, final AppConfig appConfig,
public FhirController(@SuppressWarnings("PMD.UnusedFormalParameter") final Environment environment,
final AppConfig appConfig,
final UdiPrimeJpaConfig udiPrimeJpaConfig,
final SftpManager sftpManager,
final SandboxHelpers sboxHelpers) {
@SuppressWarnings("PMD.UnusedFormalParameter") final SftpManager sftpManager,
@SuppressWarnings("PMD.UnusedFormalParameter") final SandboxHelpers sboxHelpers) {
this.appConfig = appConfig;
this.udiPrimeJpaConfig = udiPrimeJpaConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@Service
public class RoutesTrees extends HashMap<String, RoutesTree> {
public RoutesTrees(ApplicationContext applicationContext,
public RoutesTrees(@SuppressWarnings("PMD.UnusedFormalParameter") ApplicationContext applicationContext,
@Qualifier("requestMappingHandlerMapping") RequestMappingHandlerMapping handlerMapping) {
final var handlerMethods = handlerMapping.getHandlerMethods();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class ContentController {
private final Presentation presentation;

public ContentController(final Presentation presentation,
final UdiPrimeJpaConfig udiPrimeJpaConfig,
final SftpManager sftpManager,
final SandboxHelpers sboxHelpers) {
@SuppressWarnings("PMD.UnusedFormalParameter") final UdiPrimeJpaConfig udiPrimeJpaConfig,
@SuppressWarnings("PMD.UnusedFormalParameter") final SftpManager sftpManager,
@SuppressWarnings("PMD.UnusedFormalParameter") final SandboxHelpers sboxHelpers) {
this.presentation = presentation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class DataQualityController {
private final Presentation presentation;

public DataQualityController(final Presentation presentation,
final UdiPrimeJpaConfig udiPrimeJpaConfig,
final SftpManager sftpManager,
final SandboxHelpers sboxHelpers) {
@SuppressWarnings("PMD.UnusedFormalParameter") final UdiPrimeJpaConfig udiPrimeJpaConfig,
@SuppressWarnings("PMD.UnusedFormalParameter") final SftpManager sftpManager,
@SuppressWarnings("PMD.UnusedFormalParameter") final SandboxHelpers sboxHelpers) {
this.presentation = presentation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class InteractionsController {
private final SftpManager sftpManager;

public InteractionsController(final Presentation presentation,
final UdiPrimeJpaConfig udiPrimeJpaConfig,
@SuppressWarnings("PMD.UnusedFormalParameter") final UdiPrimeJpaConfig udiPrimeJpaConfig,
final SftpManager sftpManager) {
this.presentation = presentation;
this.sftpManager = sftpManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ private String convertToEST(String inputTime) {
}

@GetMapping(value = "/dashboard/stat/fhir/fhir-submission-summary", produces = "text/html")
public String fetchFHIRSubmissionSummary(Model model) {
public String fetchFHIRsubmissionSummary(Model model) {
String schemaName = "techbd_udi_ingress";
String viewName = "fhir_submission_summary";
final String DEFAULT_VALUE = "0";
String totalSubmissions = DEFAULT_VALUE;
String pendingSubmissions = DEFAULT_VALUE;
String acceptedSubmissions = DEFAULT_VALUE;
String rejectedSubmissions = DEFAULT_VALUE;
final String defaultValue = "0";
String totalSubmissions = defaultValue;
String pendingSubmissions = defaultValue;
String acceptedSubmissions = defaultValue;
String rejectedSubmissions = defaultValue;
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
viewName);
Expand All @@ -234,10 +234,10 @@ public String fetchFHIRSubmissionSummary(Model model) {
.intoMaps();
if (CollectionUtils.isNotEmpty(fhirSubmission)) {
Map<String, Object> data = fhirSubmission.get(0);
totalSubmissions = data.getOrDefault("total_submissions", DEFAULT_VALUE).toString();
pendingSubmissions = data.getOrDefault("pending_submissions", DEFAULT_VALUE).toString();
acceptedSubmissions = data.getOrDefault("accepted_submissions", DEFAULT_VALUE).toString();
rejectedSubmissions = data.getOrDefault("rejected_submissions", DEFAULT_VALUE).toString();
totalSubmissions = data.getOrDefault("total_submissions", defaultValue).toString();
pendingSubmissions = data.getOrDefault("pending_submissions", defaultValue).toString();
acceptedSubmissions = data.getOrDefault("accepted_submissions", defaultValue).toString();
rejectedSubmissions = data.getOrDefault("rejected_submissions", defaultValue).toString();
}
} catch (Exception e) {
LOG.error("Error fetching FHIR interactions", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public List<String> expectedConf() {

public DataSourceHealthCheckResult udiPrimaryDataSrcHealth() {
final var ds = udiPrimaryDataSource();
try (Connection connection = ds.getConnection()) {
try (@SuppressWarnings("PMD.UnusedLocalVariable")
Connection connection = ds.getConnection()) {
return new DataSourceHealthCheckResult(ds, null, environment,
"${${SPRING_PROFILES_ACTIVE}_TECHBD_UDI_DS_PRIME_JDBC_URL:}");
} catch (Exception e) {
Expand Down
3 changes: 2 additions & 1 deletion hub-prime/src/main/java/org/techbd/util/ArtifactStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nonnull;
import jakarta.mail.MessagingException;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -332,7 +333,7 @@ public static class Builder {
private Map<String, Object> provenance;
private PersistenceStrategy always;
private JavaMailSender mailSender;
@SuppressWarnings("unused")
@SuppressFBWarnings("URF_UNREAD_FIELD")
private ApplicationContext appCtx;

public Builder strategyJson(String strategyJson) {
Expand Down

0 comments on commit d139961

Please sign in to comment.