Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
public String getCaseId(final String caseUrn) {
try {
ignoreCertificates();
ResponseEntity<CaseMapperResponse> responseEntity = restTemplate.exchange(

Check warning on line 33 in src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

View workflow job for this annotation

GitHub Actions / pmd-analysis

Local variable 'responseEntity' could be declared final

A local variable assigned only once can be declared final. LocalVariableCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#localvariablecouldbefinal
getCaseIdUrl(caseUrn),
HttpMethod.GET,
getRequestEntity(),
CaseMapperResponse.class
);
LOG.info("CaseMapperResponse is : {} and body : {} caseurn : {} ", responseEntity.getStatusCode(), responseEntity.getBody(), caseUrn);
LOG.info(" CaseMapperResponse is : {} and body : {} caseurn : {} ", responseEntity.getStatusCode(), responseEntity.getBody(), caseUrn);

Check failure on line 39 in src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

View workflow job for this annotation

GitHub Actions / pmd-analysis

Logger calls should be surrounded by log level guards.

Whenever using a log level, one should check if it is actually enabled, or otherwise skip the associate String creation and manipulation, as well as any method calls. An alternative to checking the log level are substituting parameters, formatters or lazy logging with lambdas. The available alternatives depend on the actual logging framework. GuardLogStatement (Priority: 2, Ruleset: Best Practices) https://docs.pmd-code.org/snapshot/pmd_rules_java_bestpractices.html#guardlogstatement

if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
CaseMapperResponse body = responseEntity.getBody();

Check warning on line 42 in src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

View workflow job for this annotation

GitHub Actions / pmd-analysis

Local variable 'body' could be declared final

A local variable assigned only once can be declared final. LocalVariableCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#localvariablecouldbefinal
return body.getCaseId();
}
} catch (Exception e) {
Expand All @@ -50,14 +50,14 @@

public String getCaseMapperServiceUrl() {
if (this.caseMapperServiceUrl != null) {
LOG.info("caseMapperServiceUrl is : {}", this.caseMapperServiceUrl);
LOG.info(" caseMapperServiceUrl is : {}", this.caseMapperServiceUrl);
return this.caseMapperServiceUrl;

Check warning on line 54 in src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

View workflow job for this annotation

GitHub Actions / pmd-analysis

A method should have only one exit point, and that should be the last statement in the method

A method should have only one exit point, and that should be the last statement in the method. OnlyOneReturn (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#onlyonereturn
}
LOG.atError().log("caseMapperServiceUrl is empty");
return "https://devcp01.ingress01.dev.nl.cjscp.org.uk/urnmapper";
}

private String getCaseIdUrl(String caseUrn) {

Check warning on line 60 in src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

View workflow job for this annotation

GitHub Actions / pmd-analysis

Parameter 'caseUrn' is not assigned and could be declared final

Reports method and constructor parameters that can be made final because they are never reassigned within the body of the method. This rule ignores unused parameters so as not to overlap with the rule {% rule java/bestpractices/UnusedFormalParameter %}. It will also ignore the parameters of abstract methods. MethodArgumentCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#methodargumentcouldbefinal
LOG.atDebug().log("Fetching case id for case urn: {}", caseUrn);
return UriComponentsBuilder
.fromUriString(getCaseMapperServiceUrl())
Expand All @@ -67,7 +67,7 @@
}

private HttpEntity<String> getRequestEntity() {
HttpHeaders headers = new HttpHeaders();

Check warning on line 70 in src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

View workflow job for this annotation

GitHub Actions / pmd-analysis

Local variable 'headers' could be declared final

A local variable assigned only once can be declared final. LocalVariableCouldBeFinal (Priority: 3, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#localvariablecouldbefinal
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
return new HttpEntity<>(headers);
}
Expand Down
Loading