ilscipio/scipio-erp

View on GitHub
applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java

Summary

Maintainability
F
3 days
Test Coverage

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

    private static Document sendUspsRequest(String requestType, Document requestDocument, Delegator delegator,
            String shipmentGatewayConfigId, String resource, Locale locale) throws UspsRequestException {

    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) {

      Consider simplifying this complex logical expression.
      Open

              if ((UtilValidate.isEmpty(state) && UtilValidate.isEmpty(city) && UtilValidate.isEmpty(zip5)) ||    // No state, city or zip5
                   (UtilValidate.isEmpty(zip5) && (UtilValidate.isEmpty(state) || UtilValidate.isEmpty(city)))) {  // Both state and city are required if no zip5
                  Debug.logError("USPS address validation requires either zip5 or city and state",  module);
                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                          "FacilityShipmentUspsAddressValidationStateAndCityOrZipRqd", locale));

        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) {

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

              private static Document createUspsRequestDocument(String rootElement, boolean passwordRequired, Delegator delegator, String shipmentGatewayConfigId, String resource) {

            Avoid too many return statements within this method.
            Open

                        return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError,
                                "FacilityShipmentUspsRateDomesticSendingError", UtilMisc.toMap("errorString", e.getMessage()), 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 result;

                  Avoid too many return statements within this method.
                  Open

                              return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                      "FacilityShipmentUspsRateDomesticReadingError",
                                      UtilMisc.toMap("errorString", gee.getMessage()), 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,
                                              "FacilityShipmentUspsNoCarrierShipmentMethod",
                                              UtilMisc.toMap("carrierPartyId", partyId, "shipmentMethodTypeId", shipmentMethodTypeId), locale));

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                          "FacilityShipmentUspsWeightConversionError",
                                                          UtilMisc.toMap("errorString", ex.getMessage()), locale));

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

                                          return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError,
                                                  "FacilityShipmentRateNotAvailable", locale));

                                Avoid too many return statements within this method.
                                Open

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

                                  Avoid too many return statements within this method.
                                  Open

                                                  return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                          "FacilityShipmentUspsRouteSegmentDestinationZipCodeMissing",
                                                          UtilMisc.toMap("contactMechId", destinationAddress.getString("contactMechId")), locale));

                                    Avoid too many return statements within this method.
                                    Open

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

                                      Avoid too many return statements within this method.
                                      Open

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

                                        Avoid too many return statements within this method.
                                        Open

                                                        return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError,
                                                                "FacilityShipmentRateNotAvailable", locale));

                                          Avoid too many return statements within this method.
                                          Open

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

                                            Avoid too many return statements within this method.
                                            Open

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

                                              Avoid too many return statements within this method.
                                              Open

                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                              "FacilityShipmentUspsWeightUnsupported",
                                                                              UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"),
                                                                                      "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                      "weightUom", "WT_oz"), locale));

                                                Avoid too many return statements within this method.
                                                Open

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

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return ServiceUtil.returnSuccess();

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError,
                                                                        "FacilityShipmentUspsCityStateLookupIncompleteStateElement", locale));

                                                      Avoid too many return statements within this method.
                                                      Open

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

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                      return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                              "FacilityShipmentUspsDeliveryConfirmationReadingError",
                                                                              UtilMisc.toMap("errorString", gee.getMessage()), locale));

                                                            Avoid too many return statements within this method.
                                                            Open

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

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                          return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError,
                                                                                  "FacilityShipmentRateNotAvailable", 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,
                                                                                                  "FacilityShipmentUspsWeightUnsupported",
                                                                                                  UtilMisc.toMap("weightUomId", weightUomId, "shipmentId", shipmentPackage.getString("shipmentId"),
                                                                                                          "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                                          "weightUom", "WT_lb"), locale));

                                                                    Avoid too many return statements within this method.
                                                                    Open

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

                                                                      Avoid too many return statements within this method.
                                                                      Open

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

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                return ServiceUtil.returnSuccess();

                                                                          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,
                                                                                                    "FacilityShipmentUspsRouteSegmentOriginZipCodeMissing",
                                                                                                    UtilMisc.toMap("contactMechId", originAddress.getString("contactMechId")), locale));

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                                          return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                    return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                            "FacilityShipmentUspsRateDomesticResponseIncompleteElementPostage", 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 ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                "FacilityShipmentUspsDeliveryConfirmationResponseError",
                                                                                                                UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"),
                                                                                                                        "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId"),
                                                                                                                        "errorString", UtilXml.childElementValue(respErrorElement, "Description")), locale));

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

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

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                        return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                "FacilityShipmentUspsUnableDetermineServiceCode", 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,
                                                                                                                    "FacilityShipmentUspsRouteSegmentOriginCountryGeoNotInUsa",
                                                                                                                    UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale));

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

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

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

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

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                              return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                                                                                                                      "FacilityShipmentRateNotAvailable", 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,
                                                                                                                                  "FacilityShipmentUspsWeightNotFound",
                                                                                                                                  UtilMisc.toMap("shipmentId", shipmentPackage.getString("shipmentId"),
                                                                                                                                          "shipmentPackageSeqId", shipmentPackage.getString("shipmentPackageSeqId")), locale));

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                return ServiceUtil.returnSuccess();

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                              return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError,
                                                                                                                                      "FacilityShipmentRateNotAvailable", 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,
                                                                                                                                          "FacilityShipmentUspsRateDomesticResponseError",
                                                                                                                                          UtilMisc.toMap("errorString", UtilXml.childElementValue(respErrorElement, "Description")), 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,
                                                                                                                                              "FacilityShipmentUspsDeliveryConfirmationSendingError",
                                                                                                                                              UtilMisc.toMap("errorString", e.getMessage()), locale));

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

                                                                                                                            return responseDocument;

                                                                                                                      There are no issues that match your filters.

                                                                                                                      Category
                                                                                                                      Status