ilscipio/scipio-erp

View on GitHub
applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java

Summary

Maintainability
F
3 days
Test Coverage

Consider simplifying this complex logical expression.
Open

                if (UtilValidate.isNotEmpty(dimensionsUomId) &&
                    dimensionsLength != null && dimensionsLength.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0 &&
                    dimensionsWidth != null && dimensionsWidth.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0   &&
                    dimensionsHeight != null && dimensionsHeight.setScale(0, RoundingMode.HALF_UP).compareTo(BigDecimal.ZERO) > 0) {
                        shipRequestContext.put("DimensionsUnits", "LEN_in".equals(dimensionsUomId) ? "IN" : "CM");

    Method getShipmentGatewayConfigValue has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        private static String getShipmentGatewayConfigValue(Delegator delegator, String shipmentGatewayConfigId, String shipmentGatewayConfigParameterName,
                String resource, String parameterName, String defaultValue) {

      Avoid deeply nested control flow statements.
      Open

                                  if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                                      Debug.logWarning("Unable to convert width for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId , module);
                                      dimensionsWidth = null;
                                  } else {
                                      dimensionsWidth = (BigDecimal) results.get("convertedValue");

        Avoid deeply nested control flow statements.
        Open

                                    if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                                        Debug.logWarning("Unable to convert length for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId , module);
                                        dimensionsLength = null;
                                    } else {
                                        dimensionsLength = (BigDecimal) results.get("convertedValue");

          Avoid deeply nested control flow statements.
          Open

                                      if (ServiceUtil.isError(results) || (results.get("convertedValue") == null)) {
                                          Debug.logWarning("Unable to convert height for package " + shipmentPackage.getString("shipmentPackageSeqId") + " of shipmentRouteSegment " + shipmentRouteSegmentId + " of shipment " + shipmentId , module);
                                          dimensionsHeight = null;
                                      } else {
                                          dimensionsHeight = (BigDecimal) results.get("convertedValue");

            Method sendFedexRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static String sendFedexRequest(String xmlString, Delegator delegator, String shipmentGatewayConfigId,
                        String resource, Locale locale) throws FedexConnectException {

              Method getShipmentGatewayConfigValue has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private static String getShipmentGatewayConfigValue(Delegator delegator, String shipmentGatewayConfigId, String shipmentGatewayConfigParameterName,
                          String resource, String parameterName) {

                Avoid too many return statements within this method.
                Open

                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                        "FacilityShipmentRouteSegmentOriginPostalAddressNotComplete",
                                        UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                  Avoid too many return statements within this method.
                  Open

                                          return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                  "FacilityShipmentFedexHomeDeliveryTypeInvalid",
                                                  UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                    Avoid too many return statements within this method.
                    Open

                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                            "FacilityShipmentFedexCompanyPartyHasNotPrimaryPhoneNumber",
                                            UtilMisc.toMap("companyPartyId", companyPartyId), locale));

                      Avoid too many return statements within this method.
                      Open

                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                          "FacilityShipmentDefaultWeightUomIdNotValid", locale));

                        Avoid too many return statements within this method.
                        Open

                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                "FacilityShipmentFedexRouteSegmentCarrierShipmentMethodNotFound",
                                                UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "carrierPartyId", carrierPartyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale));

                          Avoid too many return statements within this method.
                          Open

                                          return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                  "FacilityShipmentFedexNoCarrieServiceCode",
                                                  UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId), locale));

                            Avoid too many return statements within this method.
                            Open

                                            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                    "FacilityShipmentFedexPartyToHasNoName",
                                                    UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                              Avoid too many return statements within this method.
                              Open

                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                          "FacilityShipmentFedexHomeDeliveryDateBeforeCurrentDate",
                                                          UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                Avoid too many return statements within this method.
                                Open

                                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                        "FacilityShipmentFedexCompanyPartyHasNotPostalAddress",
                                                        UtilMisc.toMap("companyPartyId", companyPartyId), locale));

                                  Avoid too many return statements within this method.
                                  Open

                                              return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                      "FacilityShipmentFedexDropoffTypeNotFound", locale));

                                    Avoid too many return statements within this method.
                                    Open

                                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                        "FacilityShipmentDefaultWeightUomIdNotFound", locale));

                                      Avoid too many return statements within this method.
                                      Open

                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                              "FacilityShipmentRouteSegmentOriginPostalAddressNotFound",
                                                              UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                        Avoid too many return statements within this method.
                                        Open

                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                            "FacilityShipmentDefaultDimensionUomIdNotFound", locale));

                                          Avoid too many return statements within this method.
                                          Open

                                                          return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                  "FacilityShipmentRouteSegmentDestPostalAddressNotFound",
                                                                  UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                            Avoid too many return statements within this method.
                                            Open

                                                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                "FacilityShipmentFedexWeightOfPackageCannotBeConverted",
                                                                                UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                        "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale));

                                              Avoid too many return statements within this method.
                                              Open

                                                      return result;

                                                Avoid too many return statements within this method.
                                                Open

                                                            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                    "FacilityShipmentFedexLabelImageTypeNotValid", locale));

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                              "FacilityShipmentRouteSegmentDestStateProvinceGeoIdNotFound",
                                                                              UtilMisc.toMap("contactMechId", destinationPostalAddress.getString("contactMechId"),
                                                                                      "shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                            "ProductShipmentNotFoundId", locale) + shipmentId);

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                              "FacilityShipmentFedexSubscriptionTemplateLocationNotFound",
                                                                              UtilMisc.toMap("templateLocation", templateLocation), locale));

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                "ProductShipmentRouteSegmentNotFound",
                                                                                UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                  "FacilityShipmentRouteSegmentOriginTelecomNumberNotFound",
                                                                                  UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                    "FacilityShipmentFedexSubscriptionTemplateParsingError",
                                                                                    UtilMisc.toMap("errorString", e.toString()), locale));

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                      "FacilityShipmentFedexPartyToRequired",
                                                                                      UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                        "FacilityShipmentFedexSubscriptionTemplateError",
                                                                                        UtilMisc.toMap("templateLocation", templateLocation, "errorString", e.getMessage()), locale));

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                          "FacilityShipmentFedexNotRouteSegmentCarrier",
                                                                                          UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale));

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                "FacilityShipmentFedexHomeDeliveryDateRequired",
                                                                                                UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                              "FacilityShipmentFedexCompanyPartyHasNoName",
                                                                                              UtilMisc.toMap("companyPartyId", companyPartyId), locale));

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                    return ServiceUtil.returnError(e.getMessage());

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                          return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                  "FacilityShipmentRouteSegmentDestTelecomNumberNotFound",
                                                                                                  UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                "FacilityShipmentFedexShipmentTemplateServiceError",
                                                                                                UtilMisc.toMap("errorString", se.toString()), locale));

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                              return ServiceUtil.returnError(errorList);

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                        "FacilityShipmentRouteSegmentOriginCountryGeoNotFound",
                                                                                                        UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                              "FacilityShipmentFedexOwnerPartyRequired",
                                                                                                              UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId,
                                                                                                                      "facilityId", originFacility.getString("facilityId")), locale));

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                "FacilityShipmentFedexWeightOfPackageNotAvailable",
                                                                                                                UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                                                        "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale));

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentPackageRouteSegsNotFound",
                                                                                                              UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                    return handleFedexShipReply(fDXShipReplyString, shipmentRouteSegment, shipmentPackageRouteSegs, locale);

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                              "FacilityShipmentDefaultDimensionUomIdNotValid", locale));

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                    "FacilityShipmentFedexOriginFacilityRequired",
                                                                                                                    UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

                                                                                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                          "FacilityShipmentFedexPackingTypeInvalid",
                                                                                                                          UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                                                                  "shipmentId", shipmentId), locale));

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

                                                                                                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                        "FacilityShipmentFedexSubscriptionTemplateSendingError",
                                                                                                                        UtilMisc.toMap("errorString", e.toString()), locale));

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                              "FacilityShipmentRouteSegmentOriginStateProvinceGeoIdRequired",
                                                                                                                              UtilMisc.toMap("contactMechId", originPostalAddress.getString("contactMechId"),
                                                                                                                                      "shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

                                                                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                            "FacilityShipmentRouteSegmentDestPostalAddressIncomplete",
                                                                                                                            UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                              "FacilityShipmentRouteSegmentDestCountryGeoNotFound",
                                                                                                                              UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                            "FacilityShipmentFedexShipmentTemplateServiceError",
                                                                                                                            UtilMisc.toMap("errorString", e.toString()), locale));

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                          return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                  "FacilityShipmentFedexPartyFromHasNoName",
                                                                                                                                  UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

                                                                                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                            "FacilityShipmentFedexPackingTypeNotConfigured",
                                                                                                                                            UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                                                                                    "shipmentId", shipmentId), locale));

                                                                                                              Avoid too many return statements within this method.
                                                                                                              Open

                                                                                                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                          "FacilityShipmentFedexPackingTypeMissing",
                                                                                                                                          UtilMisc.toMap("shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                                                                                  "shipmentId", shipmentId), locale));

                                                                                                                Avoid too many return statements within this method.
                                                                                                                Open

                                                                                                                                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                        "FacilityShipmentFedexShipmentTemplateError",
                                                                                                                                        UtilMisc.toMap("templateLocation", templateLocation, "errorString", e.getMessage()), locale));

                                                                                                                  Avoid too many return statements within this method.
                                                                                                                  Open

                                                                                                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                          "FacilityShipmentFedexRouteSegmentStatusNotStarted",
                                                                                                                                          UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId, "shipmentRouteSegmentStatus", shipmentRouteSegment.getString("carrierServiceStatusId")), locale));

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

                                                                                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                            "FacilityShipmentFedexMultiplePackagesNotSupported", locale));

                                                                                                                      Avoid too many return statements within this method.
                                                                                                                      Open

                                                                                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                              "FacilityShipmentFedexShipmentTemplateSendingError",
                                                                                                                                              UtilMisc.toMap("errorString", e.toString()), locale));

                                                                                                                        Avoid too many return statements within this method.
                                                                                                                        Open

                                                                                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                                            "FacilityShipmentFedexLabelImageTypeNotFound", locale));

                                                                                                                          There are no issues that match your filters.

                                                                                                                          Category
                                                                                                                          Status