Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIRC-1069: fix compiler warnings and some of sonar warnings #1133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,30 @@
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.fasterxml.jackson.core:jackson-core</include>
<include>javax.activation:activation</include>
<include>javax.el:javax.el-api</include>
<include>javax.ws.rs:javax.ws.rs-api</include>
<include>org.folio:mod-pubsub-client</include>
<include>jakarta.validation:jakarta.validation-api</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/module-info.*</exclude>
<exclude>META-INF/versions/**</exclude>
<exclude>javax/activation/**</exclude>
<exclude>javax/el/**</exclude>
<exclude>javax/ws/rs/**</exclude>
<exclude>org/folio/rest/jaxrs/**</exclude>
<exclude>javax/validation/**</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,32 @@ private CompletableFuture<Result<RequestAndRelatedRecords>> checkPolicy(
.mapFailure(err -> errorHandler.handleValidationError(err, REQUESTING_DISALLOWED_BY_POLICY, r)));
}

/**
* Condition for checking instance
*
* @param records Request records to be checked instance
* @return true when condition satisfies, otherwise false
*/
private CompletableFuture<Result<Boolean>> shouldCheckInstance(RequestAndRelatedRecords records) {
return ofAsync(() -> errorHandler.hasNone(INVALID_INSTANCE_ID));
}

/**
* Condition for checking item
*
* @param records Request records to be checked item
* @return true when condition satisfies, otherwise false
*/
private CompletableFuture<Result<Boolean>> shouldCheckItem(RequestAndRelatedRecords records) {
return ofAsync(() -> errorHandler.hasNone(INVALID_ITEM_ID));
}

/**
* Condition for checking policy
*
* @param records Request records to be checked policy
* @return true when condition satisfies, otherwise false
*/
private CompletableFuture<Result<Boolean>> shouldCheckPolicy(RequestAndRelatedRecords records) {
return ofAsync(() -> errorHandler.hasNone(INVALID_ITEM_ID, ITEM_DOES_NOT_EXIST,
INVALID_USER_OR_PATRON_GROUP_ID));
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/folio/circulation/domain/Loan.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.folio.circulation.domain.representations.LoanProperties.CLAIMED_RETURNED_DATE;
import static org.folio.circulation.domain.representations.LoanProperties.DATE_LOST_ITEM_SHOULD_BE_BILLED;
import static org.folio.circulation.domain.representations.LoanProperties.DECLARED_LOST_DATE;
import static org.folio.circulation.domain.representations.LoanProperties.DUEDATE_CHANGED_BY_RECALL;
import static org.folio.circulation.domain.representations.LoanProperties.DUE_DATE;
import static org.folio.circulation.domain.representations.LoanProperties.ITEM_LOCATION_ID_AT_CHECKOUT;
import static org.folio.circulation.domain.representations.LoanProperties.ITEM_STATUS;
Expand Down Expand Up @@ -121,14 +122,13 @@ public Loan changeDueDate(ZonedDateTime newDueDate) {
return this;
}

public Loan setDueDateChangedByRecall() {
write(representation, "dueDateChangedByRecall", TRUE);
public void setDueDateChangedByRecall() {
write(representation, DUEDATE_CHANGED_BY_RECALL, TRUE);

return this;
}

public Loan unsetDueDateChangedByRecall() {
write(representation, "dueDateChangedByRecall", FALSE);
write(representation, DUEDATE_CHANGED_BY_RECALL, FALSE);

return this;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public boolean isOpen() {
}

public boolean wasDueDateChangedByRecall() {
return getBooleanProperty(representation, "dueDateChangedByRecall");
return getBooleanProperty(representation, DUEDATE_CHANGED_BY_RECALL);
}

private LoanStatus getStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,8 @@ private boolean shouldChargeOverdueFineForLostItem(Loan loan) {
return false;
}

if (!loan.getLostItemPolicy().shouldRefundFees(loan.getLostDate())) {
// if the refund period has passed, do not charge fines.
return false;
}

return true;
// if the refund period has passed, do not charge fines.
return loan.getLostItemPolicy().shouldRefundFees(loan.getLostDate());
}

private CompletableFuture<Result<FeeFineAction>> createOverdueFineIfNecessary(Loan loan,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public abstract class RequestScheduledNoticeHandler extends ScheduledNoticeHandler {
protected final RequestRepository requestRepository;

public RequestScheduledNoticeHandler(Clients clients,
protected RequestScheduledNoticeHandler(Clients clients,
LoanRepository loanRepository, RequestRepository requestRepository) {

super(clients, loanRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ private LoanProperties() { }
public static final String DATE_LOST_ITEM_SHOULD_BE_BILLED = "dateLostItemShouldBeBilled";
public static final String METADATA = "metadata";
public static final String UPDATED_BY_USER_ID = "updatedByUserId";
public static final String DUEDATE_CHANGED_BY_RECALL = "dueDateChangedByRecall";
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,11 @@ private CompletableFuture<Result<Loan>> closeLoanAsLostAndPaidAndPublishEvent(Lo

private Boolean isOpenLostItemFee(Account account) {
String type = account.getFeeFineType();
if ((type.equals(FeeFine.LOST_ITEM_FEE_TYPE) || type.equals(FeeFine.LOST_ITEM_PROCESSING_FEE_TYPE)) && account.isOpen()) {
return true;
} else {
return false;
}
return (type.equals(FeeFine.LOST_ITEM_FEE_TYPE) || type.equals(FeeFine.LOST_ITEM_PROCESSING_FEE_TYPE)) && account.isOpen();
}

private Boolean hasLostItemFees(Loan loan) {
return loan.getAccounts().stream().anyMatch(account -> isOpenLostItemFee(account));
private boolean hasLostItemFees(Loan loan) {
return loan.getAccounts().stream().anyMatch(this::isOpenLostItemFee);
}

private CompletableFuture<Result<Loan>> closeLoanAsLostAndPaidAndUpdateInStorage(Loan loan) {
Expand Down