Skip to content

Commit

Permalink
Improved: Handle remaining checkstyle errors (OFBIZ-12169)
Browse files Browse the repository at this point in the history
This handles the "'(' should be on the previous line?" rule of MethodParamPad

Actually not completely, because there are still some cases that can't be
handled by changing code, notably when a casting is necessary. I believe there
is an error in checkstyle code. I'll discuss that in dev ML before sending
checkstyle team a report.
  • Loading branch information
JacquesLeRoux committed May 4, 2021
1 parent 3f2fbc6 commit 45f50c9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ public static Map<String, Object> createInvoiceForOrder(DispatchContext dctx, Ma
Map<String, Object> createInvoiceItemContext = new HashMap<>();
createInvoiceItemContext.put("invoiceId", invoiceId);
createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId);
createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, (orderItem.getString("orderItemTypeId")),
(product == null ? null : product.getString("productTypeId")), invoiceType, "INV_FPROD_ITEM"));
createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, orderItem.getString("orderItemTypeId"),
product == null ? null : product.getString("productTypeId"), invoiceType, "INV_FPROD_ITEM"));
createInvoiceItemContext.put("description", orderItem.get("itemDescription"));
createInvoiceItemContext.put("quantity", billingQuantity);
createInvoiceItemContext.put("amount", billingAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,8 @@ public static Map<String, Object> processRefundReturn(DispatchContext dctx, Map<
orderPayPrefDetails.put("orderPaymentPreference", orderPayPref);
orderPayPrefDetails.put("availableTotal", orderPayPrefAvailableTotal);
if (prefSplitMap.containsKey(paymentMethodTypeId)) {
(prefSplitMap.get(paymentMethodTypeId)).add(orderPayPrefDetails);
List<Map<String, Object>> paymentMethodTypeIds = prefSplitMap.get(paymentMethodTypeId);
paymentMethodTypeIds.add(orderPayPrefDetails);
} else {
prefSplitMap.put(paymentMethodTypeId, UtilMisc.toList(orderPayPrefDetails));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1759,8 +1759,8 @@ public void clear() {
this.orderAttributes.clear();

// clear the additionalPartyRole Map
for (Map.Entry<String, List<String>> me : this.additionalPartyRole.entrySet()) {
((LinkedList<String>) me.getValue()).clear();
for (Entry<String, List<String>> me : this.additionalPartyRole.entrySet()) {
me.getValue().clear();
}
this.additionalPartyRole.clear();

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ checkstyle {
// the sum of errors found last time it was changed after using the
// ‘checkstyle’ tool present in the framework and in the official
// plugins.
tasks.checkstyleMain.maxErrors = 127
tasks.checkstyleMain.maxErrors = 116
// Currently there are a lot of errors so we need to temporarily
// hide them to avoid polluting the terminal output.
showViolations = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static String getJSONuiLabelArray(HttpServletRequest request, HttpServlet
Map<String, List<String>> uiLabelObject = null;
if (UtilValidate.isNotEmpty(jsonString)) {
JSON json = JSON.from(jsonString);
uiLabelObject = UtilGenerics.<Map<String, List<String>>> cast(json.toObject(Map.class));
uiLabelObject = UtilGenerics.cast(json.toObject(Map.class));
}
if (UtilValidate.isEmpty(uiLabelObject)) {
Debug.logError("No resource and labels found in JSON string: " + jsonString, MODULE);
Expand Down Expand Up @@ -307,7 +307,7 @@ public static String getJSONuiLabel(HttpServletRequest request, HttpServletRespo
Map<String, String> uiLabelObject = null;
if (UtilValidate.isNotEmpty(jsonString)) {
JSON json = JSON.from(jsonString);
uiLabelObject = UtilGenerics.<Map<String, String>> cast(json.toObject(Map.class));
uiLabelObject = UtilGenerics.cast(json.toObject(Map.class));
}
if (UtilValidate.isEmpty(uiLabelObject)) {
Debug.logError("No resource and labels found in JSON string: " + jsonString, MODULE);
Expand Down Expand Up @@ -404,8 +404,7 @@ public static String getCaptcha(HttpServletRequest request, HttpServletResponse
charGraphics.setFont(textFont);

int charX = (int) (0.5 * charDim - 0.5 * charWidth);
charGraphics.drawString("" + captchaCode.charAt(i), charX,
((charDim - fontMetrics.getAscent()) / 2 + fontMetrics.getAscent()));
charGraphics.drawString("" + captchaCode.charAt(i), charX, (charDim - fontMetrics.getAscent()) / 2 + fontMetrics.getAscent());

float x = horizMargin + spacePerChar * (i) - charDim / 2.0f;
int y = ((height - charDim) / 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
GenericValue tenant = EntityQuery.use(baseDelegator).from("Tenant").where("tenantId", tenantId).queryOne();
String initialPath = tenant.getString("initialPath");
if (UtilValidate.isNotEmpty(initialPath) && !"/".equals(initialPath)) {
((HttpServletResponse) response).sendRedirect(initialPath);
httpResponse.sendRedirect(initialPath);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static Map<String, Object> entityImportDir(DispatchContext dctx, Map<Stri
lastUnprocessedFilesCount = unprocessedFiles.size();
messages.add("---------------------------------------");
messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportSucceededNumberFile", UtilMisc.toMap("succeeded",
(initialListSize - lastUnprocessedFilesCount), "total", initialListSize), locale));
initialListSize - lastUnprocessedFilesCount, "total", initialListSize), locale));
messages.add(UtilProperties.getMessage(RESOURCE, "EntityImportFailedNumberFile", UtilMisc.toMap("failed",
lastUnprocessedFilesCount, "total", initialListSize), locale));
messages.add("---------------------------------------");
Expand Down

0 comments on commit 45f50c9

Please sign in to comment.