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

Address linting ssues #42

Open
tenthirtyam opened this issue Jan 7, 2025 · 0 comments · Fixed by #59, #58, #56 or #60 · May be fixed by #54
Open

Address linting ssues #42

tenthirtyam opened this issue Jan 7, 2025 · 0 comments · Fixed by #59, #58, #56 or #60 · May be fixed by #54
Assignees
Labels
technical-debt Technical Debt
Milestone

Comments

@tenthirtyam
Copy link
Contributor

tenthirtyam commented Jan 7, 2025

Technical Debt:

Address issues found running golangci-lint run or make lint:

~/Code/terraform-provider-hcx git:[main]
make lint
==> Checking source code against linters...
hcx/activation.go:38:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/activation.go:97:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/certificate.go:29:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/client.go:117:16: Error return value of `xml.Unmarshal` is not checked (errcheck)
                xml.Unmarshal(body, &xmlmessage)
                             ^
hcx/compute_profile.go:105:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/l2_extension.go:83:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/location.go:36:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/network_profile.go:77:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/network_profile.go:114:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/network_profile.go:157:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/network_profile.go:222:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/role_mapping.go:31:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/service_mesh.go:68:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/site_pairing.go:69:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/sso.go:78:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/sso.go:109:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:305:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:345:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:384:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:464:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:509:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:552:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:589:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:627:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/utils.go:672:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/vcenter.go:48:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/vmc.go:102:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
hcx/client.go:84:92: G402: TLS InsecureSkipVerify set true. (gosec)
        http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
                                                                                                  ^
hcx/client.go:177:92: G402: TLS InsecureSkipVerify set true. (gosec)
        http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
                                                                                                  ^
hcx/client.go:212:92: G402: TLS InsecureSkipVerify set true. (gosec)
        http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
                                                                                                  ^
hcx/client.go:244:92: G402: TLS InsecureSkipVerify set true. (gosec)
        http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
                                                                                                  ^
hcx/sso.go:27:2: var-naming: struct field LookupServiceUrl should be LookupServiceURL (revive)
        LookupServiceUrl string `json:"lookupServiceUrl"`
        ^
hcx/l2_extension.go:16:2: var-naming: struct field VcGuid should be VcGUID (revive)
        VcGuid             string             `json:"vcGuid"`
        ^
hcx/l2_extension.go:19:2: var-naming: struct field Dns should be DNS (revive)
        Dns                []string           `json:"dns"`
        ^
hcx/l2_extension.go:28:2: var-naming: struct field GatewayId should be GatewayID (revive)
        GatewayId string `json:"gatewayId"`
        ^
hcx/l2_extension.go:32:2: var-naming: struct field EndpointId should be EndpointID (revive)
        EndpointId   string `json:"endpointId"`
        ^
hcx/l2_extension.go:35:2: var-naming: struct field ResourceId should be ResourceID (revive)
        ResourceId   string `json:"resourceId"`
        ^
hcx/l2_extension.go:46:2: var-naming: struct field ApplianceId should be ApplianceID (revive)
        ApplianceId string `json:"applianceId"`
        ^
hcx/l2_extension.go:50:2: var-naming: struct field NetworkId should be NetworkID (revive)
        NetworkId   string `json:"networkId"`
        ^
hcx/l2_extension.go:64:2: var-naming: struct field StretchId should be StretchID (revive)
        StretchId       string          `json:"stretchId"`
        ^
hcx/l2_extension.go:109:33: var-naming: don't use underscores in Go names; func parameter network_name should be networkName (revive)
func GetL2Extensions(c *Client, network_name string) (GetL2ExtensionsResultItem, error) {
                                ^
hcx/compute_profile.go:27:2: var-naming: struct field CmpId should be CmpID (revive)
        CmpId   string `json:"cmpId"`
        ^
hcx/compute_profile.go:36:2: var-naming: struct field CmpId should be CmpID (revive)
        CmpId   string `json:"cmpId"`
        ^
hcx/compute_profile.go:46:2: var-naming: struct field CpuReservation should be CPUReservation (revive)
        CpuReservation    int       `json:"cpuReservation"`
        ^
hcx/compute_profile.go:80:2: var-naming: struct field InterconnectTaskId should be InterconnectTaskID (revive)
        InterconnectTaskId string `json:"interconnectTaskId"`
        ^
hcx/compute_profile.go:81:2: var-naming: struct field ComputeProfileId should be ComputeProfileID (revive)
        ComputeProfileId   string `json:"computeProfileId"`
        ^
hcx/compute_profile.go:89:2: var-naming: struct field ComputeProfileId should be ComputeProfileID (revive)
        ComputeProfileId     string              `json:"computeProfileId"`
        ^
hcx/compute_profile.go:159:35: var-naming: func parameter endpointId should be endpointID (revive)
func GetComputeProfile(c *Client, endpointId string, computeprofileName string) (GetComputeProfileResultItem, error) {
                                  ^
hcx/role_mapping.go:22:2: var-naming: struct field HttpStatusCode should be HTTPStatusCode (revive)
        HttpStatusCode int    `json:"httpStatusCode"`
        ^
hcx/service_mesh.go:15:2: var-naming: struct field ComputeProfileId should be ComputeProfileID (revive)
        ComputeProfileId   string `json:"computeProfileId"`
        ^
hcx/service_mesh.go:17:2: var-naming: struct field EndpointId should be EndpointID (revive)
        EndpointId         string `json:"endpointId"`
        ^
hcx/service_mesh.go:27:2: var-naming: struct field IsTcpFlowConditioningEnabled should be IsTCPFlowConditioningEnabled (revive)
        IsTcpFlowConditioningEnabled bool `json:"isTcpFlowConditioningEnabled"`
        ^
hcx/service_mesh.go:49:2: var-naming: struct field InterconnectTaskId should be InterconnectTaskID (revive)
        InterconnectTaskId string `json:"interconnectTaskId"`
        ^
hcx/service_mesh.go:50:2: var-naming: struct field ServiceMeshId should be ServiceMeshID (revive)
        ServiceMeshId      string `json:"serviceMeshId"`
        ^
hcx/service_mesh.go:58:2: var-naming: struct field InterconnectTaskId should be InterconnectTaskID (revive)
        InterconnectTaskId string `json:"interconnectTaskId"`
        ^
hcx/location.go:17:2: var-naming: struct field CityAscii should be CityASCII (revive)
        CityAscii string  `json:"cityAscii"`
        ^
hcx/location.go:27:2: var-naming: struct field CityAscii should be CityASCII (revive)
        CityAscii string  `json:"cityAscii"`
        ^
hcx/service_mesh.go:59:2: var-naming: struct field ServiceMeshId should be ServiceMeshID (revive)
        ServiceMeshId      string `json:"serviceMeshId"`
        ^
hcx/vmc.go:43:6: exported: type name will be used as hcx.HcxCloudAuthorizationBody by other packages, and that stutters; consider calling this CloudAuthorizationBody (revive)
type HcxCloudAuthorizationBody struct {
     ^
hcx/vmc.go:90:6: exported: func name will be used as hcx.HcxCloudAuthenticate by other packages, and that stutters; consider calling this CloudAuthenticate (revive)
func HcxCloudAuthenticate(client *Client, token string) error {
     ^
hcx/site_pairing.go:14:6: var-naming: don't use underscores in Go names; type Remote_data should be RemoteData (revive)
type Remote_data struct {
     ^
hcx/site_pairing.go:18:2: var-naming: struct field EndpointId should be EndpointID (revive)
        EndpointId string `json:"endpointId,omitempty"`
        ^
hcx/site_pairing.go:123:36: var-naming: func parameter endpointId should be endpointID (revive)
func DeleteSitePairings(c *Client, endpointId string) (DeleteRemoteCloudConfigResult, error) {
                                   ^
hcx/vmc.go:131:36: var-naming: don't use underscores in Go names; func parameter sddc_name should be sddcName (revive)
func GetSddcByName(client *Client, sddc_name string) (SDDC, error) {
                                   ^
hcx/vmc.go:205:40: var-naming: don't use underscores in Go names; func parameter sddc_id should be sddcID (revive)
func ActivateHcxOnSDDC(client *Client, sddc_id string) (ActivateHcxOnSDDCResults, error) {
                                       ^
hcx/vmc.go:237:42: var-naming: don't use underscores in Go names; func parameter sddc_id should be sddcID (revive)
func DeactivateHcxOnSDDC(client *Client, sddc_id string) (DeactivateHcxOnSDDCResults, error) {
                                         ^
hcx/network_profile.go:24:2: var-naming: struct field ObjectId should be ObjectID (revive)
        ObjectId        string    `json:"objectId,omitempty"`
        ^
hcx/network_profile.go:40:2: var-naming: struct field VCenterInstanceUuid should be VCenterInstanceUUID (revive)
        VCenterInstanceUuid string `json:"vCenterInstanceUuid"`
        ^
hcx/network_profile.go:45:2: var-naming: struct field DnsSuffix should be DNSSuffix (revive)
        DnsSuffix       string           `json:"dnsSuffix,omitempty"`
        ^
hcx/network_profile.go:48:2: var-naming: struct field PrimaryDns should be PrimaryDNS (revive)
        PrimaryDns      string           `json:"primaryDns,omitempty"`
        ^
hcx/network_profile.go:49:2: var-naming: struct field SecondaryDns should be SecondaryDNS (revive)
        SecondaryDns    string           `json:"secondaryDns,omitempty"`
        ^
hcx/network_profile.go:50:2: var-naming: struct field NetworkIpRanges should be NetworkIPRanges (revive)
        NetworkIpRanges []NetworkIpRange `json:"networkIpRanges,omitempty"`
        ^
hcx/network_profile.go:54:6: var-naming: type NetworkIpRange should be NetworkIPRange (revive)
type NetworkIpRange struct {
     ^
hcx/network_profile.go:68:2: var-naming: struct field ObjectId should be ObjectID (revive)
        ObjectId string `json:"objectId"`
        ^
hcx/network_profile.go:146:6: var-naming: func GetNetworkProfileById should be GetNetworkProfileByID (revive)
func GetNetworkProfileById(c *Client, id string) (NetworkProfileBody, error) {
     ^
hcx/client.go:55:6: var-naming: don't use underscores in Go names; type enterprise_get_object_groups should be enterpriseGetObjectGroups (revive)
type enterprise_get_object_groups struct {
     ^
hcx/client.go:119:3: var-naming: don't use underscores in Go names; var certificate_pb should be certificatePb (revive)
                certificate_pb := false
                ^
hcx/client.go:145:103: var-naming: don't use underscores in Go names; func parameter vmc_token should be vmcToken (revive)
func NewClient(hcx, username *string, password *string, adminusername *string, adminpassword *string, vmc_token *string) (*Client, error) {
                                                                                                      ^
hcx/utils.go:16:6: var-naming: don't use underscores in Go names; type Job_result should be JobResult (revive)
type Job_result struct {
     ^
hcx/utils.go:34:6: var-naming: don't use underscores in Go names; type Task_result should be TaskResult (revive)
type Task_result struct {
     ^
hcx/utils.go:35:2: var-naming: struct field InterconnectTaskId should be InterconnectTaskID (revive)
        InterconnectTaskId string `json:"interconnectTaskId"`
        ^
hcx/client.go:45:6: type `updateConfigurationModule` is unused (unused)
type updateConfigurationModule struct {
     ^
hcx/client.go:50:6: type `updateConfigurationModuleBody` is unused (unused)
type updateConfigurationModuleBody struct {
     ^
hcx/client.go:175:39: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
        req.Header.Set("x-hm-authorization", fmt.Sprintf("%s", c.Token))
                                             ^
hcx/client.go:242:40: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
                req.Header.Set("x-hm-authorization", fmt.Sprintf("%s", c.HcxToken))
                                                     ^
resource_compute_profile.go:293:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
resource_l2_extension.go:150:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
resource_service_mesh.go:175:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
        json.NewEncoder(buf).Encode(body)
                                   ^
resource_sso.go:121:15: Error return value of `hcx.DeleteSSO` is not checked (errcheck)
        hcx.DeleteSSO(client, d.Id())
                     ^
resource_vcenter.go:73:19: Error return value of `hcx.AppEngineStop` is not checked (errcheck)
        hcx.AppEngineStop(client)
                         ^
resource_vcenter.go:88:20: Error return value of `hcx.AppEngineStart` is not checked (errcheck)
        hcx.AppEngineStart(client)
                          ^
resource_vcenter.go:124:19: Error return value of `hcx.DeletevCenter` is not checked (errcheck)
        hcx.DeletevCenter(client, d.Id())
                         ^
make: *** [lint] Error 1
➜ staticcheck
resource_compute_profile.go:323:24: error strings should not be capitalized (ST1005)
resource_compute_profile.go:368:24: error strings should not be capitalized (ST1005)
resource_service_mesh.go:208:24: error strings should not be capitalized (ST1005)
resource_service_mesh.go:269:24: error strings should not be capitalized (ST1005)
@tenthirtyam tenthirtyam self-assigned this Jan 7, 2025
@github-actions github-actions bot added the pending-review Pending Review label Jan 7, 2025
@tenthirtyam tenthirtyam added technical-debt Technical Debt and removed pending-review Pending Review labels Jan 7, 2025
@tenthirtyam tenthirtyam modified the milestones: .next, v0.4.4, Backlog Jan 7, 2025
@tenthirtyam tenthirtyam linked a pull request Jan 22, 2025 that will close this issue
11 tasks
tenthirtyam added a commit that referenced this issue Jan 22, 2025
Removd format for arguments that are already a string.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 22, 2025
Removed format for arguments that are already a string.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam linked a pull request Jan 22, 2025 that will close this issue
11 tasks
@tenthirtyam tenthirtyam linked a pull request Jan 22, 2025 that will close this issue
11 tasks
This was referenced Jan 22, 2025
tenthirtyam added a commit that referenced this issue Jan 22, 2025
Removes unused structs from the `hcx/client.go` file to clean up the codebase.

* Removed the `updateConfigurationModule` struct, which was not being used.
* Removed the `updateConfigurationModuleBody` struct, which was not being used.
* Removed the `enterprise_get_object_groups` struct, which was not being used.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 23, 2025
Removes the use of underscores in Go names.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam linked a pull request Jan 23, 2025 that will close this issue
11 tasks
@tenthirtyam tenthirtyam linked a pull request Jan 23, 2025 that will close this issue
11 tasks
tenthirtyam added a commit that referenced this issue Jan 23, 2025
Use Shorthand Increment Operator: Replace `errcount += 1` with `errcount++`, as it is a more concise and conventional way to increment an integer by 1 in Go. This minor refactoring improves code readability and aligns with common Go practices.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 23, 2025
- Updates `HcxCloudAuthorizationBody` to `CloudAuthorizationBody`.
- Updates `HcxCloudAuthenticate` to `CloudAuthenticate`.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam mentioned this issue Jan 23, 2025
11 tasks
tenthirtyam added a commit that referenced this issue Jan 23, 2025
Removes the use of underscores in Go names.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
- Updates `HcxCloudAuthorizationBody` to `CloudAuthorizationBody`.
- Updates `HcxCloudAuthenticate` to `CloudAuthenticate`.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Removed format for arguments that are already a string.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Use Shorthand Increment Operator: Replace `errcount += 1` with `errcount++`, as it is a more concise and conventional way to increment an integer by 1 in Go. This minor refactoring improves code readability and aligns with common Go practices.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Use Shorthand Increment Operator: Replace `errcount += 1` with `errcount++`, as it is a more concise and conventional way to increment an integer by 1 in Go. This minor refactoring improves code readability and aligns with common Go practices.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Removed format for arguments that are already a string.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam reopened this Jan 24, 2025
@tenthirtyam tenthirtyam linked a pull request Jan 24, 2025 that will close this issue
11 tasks
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Removed format for arguments that are already a string.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Removed format for arguments that are already a string.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Removes the use of underscores in Go names.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
tenthirtyam added a commit that referenced this issue Jan 24, 2025
Removes the use of underscores in Go names.

Ref: #42

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam reopened this Jan 24, 2025
@tenthirtyam tenthirtyam changed the title Address golangci-lint issues Address linting ssues Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment