From c018624f729cd4df95ed140f801623d294e028f8 Mon Sep 17 00:00:00 2001 From: Ginny Guan Date: Mon, 26 Feb 2024 11:24:33 +0800 Subject: [PATCH] EDX-4721 Remove unused variables and function to fix lint Signed-off-by: Ginny Guan --- clients/http/utils/central.go | 9 --------- common/validator.go | 4 ++-- dtos/deviceprofile.go | 8 ++++---- dtos/deviceservice.go | 4 ++-- dtos/reading_test.go | 1 - dtos/requests/provisionwatcher_test.go | 4 ---- models/deviceresource.go | 2 +- xrtmodels/deviceInfo.go | 2 +- 8 files changed, 10 insertions(+), 24 deletions(-) diff --git a/clients/http/utils/central.go b/clients/http/utils/central.go index 2ab8c610..b31595c0 100644 --- a/clients/http/utils/central.go +++ b/clients/http/utils/central.go @@ -15,15 +15,6 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v3/errors" ) -// edgeXClientReqURI returns the non-encoded path?query that would be used in an HTTP request for u. -func edgeXClientReqURI(u *url.URL) string { - result := u.Scheme + "://" + u.Host + u.Path - if u.ForceQuery || u.RawQuery != "" { - result += "?" + u.RawQuery - } - return result -} - // CentralGetRequest makes the get request and return the body func CentralGetRequest(ctx context.Context, returnValuePointer interface{}, baseUrl string, requestPath string, requestParams url.Values, authInjector interfaces.AuthenticationInjector) errors.EdgeX { req, edgexErr := createRequest(ctx, http.MethodGet, baseUrl, requestPath, requestParams) diff --git a/common/validator.go b/common/validator.go index 9f268f14..20224c62 100644 --- a/common/validator.go +++ b/common/validator.go @@ -45,14 +45,14 @@ const ( name = "Name" // Central - reservedCharsRegexString = "^[^/#+$]+$" + reservedCharsRegexString = "^[^/#+$]+$" ) var ( rFC3986UnreservedCharsRegex = regexp.MustCompile(rFC3986UnreservedCharsRegexString) // Central - reservedCharsRegex = regexp.MustCompile(reservedCharsRegexString) + reservedCharsRegex = regexp.MustCompile(reservedCharsRegexString) ) func init() { diff --git a/dtos/deviceprofile.go b/dtos/deviceprofile.go index 6b9a5bb7..6a03a4c9 100644 --- a/dtos/deviceprofile.go +++ b/dtos/deviceprofile.go @@ -22,7 +22,7 @@ type DeviceProfile struct { DeviceCommands []DeviceCommand `json:"deviceCommands" yaml:"deviceCommands" validate:"dive"` // Central - ApiVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` + ApiVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` } // Validate satisfies the Validator interface @@ -46,7 +46,7 @@ func (dp *DeviceProfile) UnmarshalYAML(unmarshal func(interface{}) error) error DeviceCommands []DeviceCommand `yaml:"deviceCommands"` // Central - ApiVersion string `yaml:"apiVersion"` + ApiVersion string `yaml:"apiVersion"` } if err := unmarshal(&alias); err != nil { return edgexErrors.NewCommonEdgeX(edgexErrors.KindContractInvalid, "failed to unmarshal request body as YAML.", err) @@ -82,7 +82,7 @@ func ToDeviceProfileModel(deviceProfileDTO DeviceProfile) models.DeviceProfile { DeviceCommands: ToDeviceCommandModels(deviceProfileDTO.DeviceCommands), // Central - ApiVersion: deviceProfileDTO.ApiVersion, + ApiVersion: deviceProfileDTO.ApiVersion, } } @@ -105,7 +105,7 @@ func FromDeviceProfileModelToDTO(deviceProfile models.DeviceProfile) DeviceProfi DeviceCommands: FromDeviceCommandModelsToDTOs(deviceProfile.DeviceCommands), // Central - ApiVersion: deviceProfile.ApiVersion, + ApiVersion: deviceProfile.ApiVersion, } } diff --git a/dtos/deviceservice.go b/dtos/deviceservice.go index 8ba47c16..d1705de7 100644 --- a/dtos/deviceservice.go +++ b/dtos/deviceservice.go @@ -19,7 +19,7 @@ type DeviceService struct { AdminState string `json:"adminState" validate:"oneof='LOCKED' 'UNLOCKED'"` // Central - TransformScript string `json:"transformScript,omitempty"` + TransformScript string `json:"transformScript,omitempty"` } type UpdateDeviceService struct { @@ -31,7 +31,7 @@ type UpdateDeviceService struct { AdminState *string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"` // Central - TransformScript *string `json:"transformScript"` + TransformScript *string `json:"transformScript"` } // ToDeviceServiceModel transforms the DeviceService DTO to the DeviceService Model diff --git a/dtos/reading_test.go b/dtos/reading_test.go index 86b04548..1652672b 100644 --- a/dtos/reading_test.go +++ b/dtos/reading_test.go @@ -429,7 +429,6 @@ func TestUnmarshalObjectValueError(t *testing.T) { // Central - func TestNewObjectArrayReading(t *testing.T) { expectedDeviceName := TestDeviceName expectedProfileName := TestDeviceProfileName diff --git a/dtos/requests/provisionwatcher_test.go b/dtos/requests/provisionwatcher_test.go index 4db432dd..7174e446 100644 --- a/dtos/requests/provisionwatcher_test.go +++ b/dtos/requests/provisionwatcher_test.go @@ -27,10 +27,6 @@ var testIdentifiers = map[string]string{ var testBlockingIdentifiers = map[string][]string{ "port": {"397", "398", "399"}, } -var testDeviceDescription = "test device description" -var testDeviceNamePattern = "device-name-{{Address}}-{{Port}}" -var testProfileNamePattern = "profile-name-{{Address}}-{{Port}}" -var testProfileDescription = "test profile description" var testAddProvisionWatcher = AddProvisionWatcherRequest{ BaseRequest: common.BaseRequest{ RequestId: ExampleUUID, diff --git a/models/deviceresource.go b/models/deviceresource.go index 07eef560..68cc2636 100644 --- a/models/deviceresource.go +++ b/models/deviceresource.go @@ -14,5 +14,5 @@ type DeviceResource struct { Tags map[string]any // Central - Tag string + Tag string } diff --git a/xrtmodels/deviceInfo.go b/xrtmodels/deviceInfo.go index e63ebda8..43634846 100644 --- a/xrtmodels/deviceInfo.go +++ b/xrtmodels/deviceInfo.go @@ -43,7 +43,7 @@ func ToEdgeXV2Device(device DeviceInfo, serviceName string) v2models.Device { // ToEdgeXV3Device converts the XRT model to EdgeX v3 model func ToEdgeXV3Device(device DeviceInfo, serviceName string) models.Device { - for protocol, _ := range device.Protocols { + for protocol := range device.Protocols { device.Properties[common.ProtocolName] = strings.ToLower(protocol) } return models.Device{