paraglider-project / paraglider

Streamlining cloud networking
https://paragliderproject.io
Apache License 2.0
61 stars 4 forks source link

Fix linter errors in orchestrator package #377

Open praveingk opened 5 months ago

praveingk commented 5 months ago

Steps to reproduce: 1) Replace .golangci.yml to this version 2) Run golangci-lint run --config=./.golangci.yaml ./pkg/orchestrator/...

pkg/orchestrator/config/config.go:33:2: var-naming: struct field RpcPort should be RPCPort (revive)
pkg/orchestrator/orchestrator.go:74:2: var-naming: struct field usedBgpPeeringIpAddresses should be usedBgpPeeringIPAddresses (revive)
pkg/orchestrator/orchestrator.go:90:2: var-naming: don't use underscores in Go names; var new_tokens should be newTokens (revive)
pkg/orchestrator/orchestrator.go:91:44: unnecessary conversion (unconvert)
pkg/orchestrator/orchestrator.go:106:6: var-naming: func isIpAddrOrCidr should be isIPAddrOrCidr (revive)
pkg/orchestrator/orchestrator.go:110:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
pkg/orchestrator/orchestrator.go:125: line is 141 characters (lll)
pkg/orchestrator/orchestrator.go:138:1: paramTypeCombine: func(namespace string, cloud string, uri string) string could be replaced with func(namespace, cloud, uri string) string (gocritic)
pkg/orchestrator/orchestrator.go:143:1: unnamedResult: consider giving a name to these results (gocritic)
pkg/orchestrator/orchestrator.go:151:1: paramTypeCombine: func(namespace string, cloud string, tag string) string could be replaced with func(namespace, cloud, tag string) string (gocritic)
pkg/orchestrator/orchestrator.go:156:28: var-naming: method getTagUri should be getTagURI (revive)
pkg/orchestrator/orchestrator.go:195:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
pkg/orchestrator/orchestrator.go:201: line is 169 characters (lll)
pkg/orchestrator/orchestrator.go:210:4: `if !isIpAddrOrCidr(tag)` has complex nested blocks (complexity: 6) (nestif)
pkg/orchestrator/orchestrator.go:215:5: deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop (gocritic)
pkg/orchestrator/orchestrator.go:246:1: paramTypeCombine: func(namespace string, resourceId string, pluginAddress string) (*paragliderpb.GetPermitListResponse, error) could be replaced with func(namespace, resourceId, pluginAddress string) (*paragliderpb.GetPermitListResponse, error) (gocritic)
pkg/orchestrator/orchestrator.go:256:2: var-naming: var emptyresourceId should be emptyresourceID (revive)
pkg/orchestrator/orchestrator.go:284: line is 189 characters (lll)
pkg/orchestrator/orchestrator.go:333:46: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:347:25: "PUT" can be replaced by http.MethodPut (usestdlibvars)
pkg/orchestrator/orchestrator.go:357: line is 159 characters (lll)
pkg/orchestrator/orchestrator.go:367:1: paramTypeCombine: func(beforeList []*paragliderpb.PermitListRule, afterList []*paragliderpb.PermitListRule) []string could be replaced with func(beforeList, afterList []*paragliderpb.PermitListRule) []string (gocritic)
pkg/orchestrator/orchestrator.go:399:1: paramTypeCombine: func(resource *ResourceInfo, beforeList []*paragliderpb.PermitListRule, afterList []*paragliderpb.PermitListRule) error could be replaced with func(resource *ResourceInfo, beforeList, afterList []*paragliderpb.PermitListRule) error (gocritic)
pkg/orchestrator/orchestrator.go:418: line is 226 characters (lll)
pkg/orchestrator/orchestrator.go:428:50: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:452: line is 167 characters (lll)
pkg/orchestrator/orchestrator.go:459: line is 139 characters (lll)
pkg/orchestrator/orchestrator.go:467: line is 166 characters (lll)
pkg/orchestrator/orchestrator.go:483:49: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:507: line is 167 characters (lll)
pkg/orchestrator/orchestrator.go:514: line is 148 characters (lll)
pkg/orchestrator/orchestrator.go:522: line is 166 characters (lll)
pkg/orchestrator/orchestrator.go:576: line is 173 characters (lll)
pkg/orchestrator/orchestrator.go:577: line is 176 characters (lll)
pkg/orchestrator/orchestrator.go:578:34: Function `updateUsedAddressSpaces->getAddressSpaces` should pass the context parameter (contextcheck)
pkg/orchestrator/orchestrator.go:617: line is 138 characters (lll)
pkg/orchestrator/orchestrator.go:618:34: Function `updateUsedAddressSpaces->getAddressSpaces` should pass the context parameter (contextcheck)
pkg/orchestrator/orchestrator.go:634:15: ST1005: error strings should not be capitalized (stylecheck)
pkg/orchestrator/orchestrator.go:640:15: ST1005: error strings should not be capitalized (stylecheck)
pkg/orchestrator/orchestrator.go:656:11: ST1005: error strings should not be capitalized (stylecheck)
pkg/orchestrator/orchestrator.go:663: line is 144 characters (lll)
pkg/orchestrator/orchestrator.go:664:25: Function `updateUsedAsns->getUsedAsns` should pass the context parameter (contextcheck)
pkg/orchestrator/orchestrator.go:675:25: var-declaration: should drop = 0 from declaration of var unusedAsn; it is the zero value (revive)
pkg/orchestrator/orchestrator.go:702: line is 131 characters (lll)
pkg/orchestrator/orchestrator.go:706:15: ST1005: error strings should not be capitalized (stylecheck)
pkg/orchestrator/orchestrator.go:712:15: ST1005: error strings should not be capitalized (stylecheck)
pkg/orchestrator/orchestrator.go:724:60: unused-parameter: parameter 'namespace' seems to be unused, consider removing or renaming it as _ (revive)
pkg/orchestrator/orchestrator.go:726:3: var-naming: var bgpPeeringIpAddressesList should be bgpPeeringIPAddressesList (revive)
pkg/orchestrator/orchestrator.go:728:11: ST1005: error strings should not be capitalized (stylecheck)
pkg/orchestrator/orchestrator.go:736:1: paramTypeCombine: func(ctx context.Context, cloud1 string, cloud2 string, namespace string) ([]string, error) could be replaced with func(ctx context.Context, cloud1, cloud2, namespace string) ([]string, error) (gocritic)
pkg/orchestrator/orchestrator.go:738:42: Function `updateUsedBgpPeeringIpAddresses->getUsedBgpPeeringIpAddresses` should pass the context parameter (contextcheck)
pkg/orchestrator/orchestrator.go:744:2: var-naming: var usedBgpPeeringIpAddresses should be usedBgpPeeringIPAddresses (revive)
pkg/orchestrator/orchestrator.go:745:9: var-naming: range var cloudBgpPeeringIpAddresses should be cloudBgpPeeringIPAddresses (revive)
pkg/orchestrator/orchestrator.go:756: line is 146 characters (lll)
pkg/orchestrator/orchestrator.go:757:6: var-naming: var minIp should be minIP (revive)
pkg/orchestrator/orchestrator.go:768: line is 132 characters (lll)
pkg/orchestrator/orchestrator.go:778: line is 138 characters (lll)
pkg/orchestrator/orchestrator.go:825: line is 148 characters (lll)
pkg/orchestrator/orchestrator.go:831:2: `if utils.MatchCloudProviders(req.CloudA, req.CloudB, utils.AZURE, utils.GCP)` has complex nested blocks (complexity: 10) (nestif)
pkg/orchestrator/orchestrator.go:857:3: var-naming: var bgpPeeringIpAddresses should be bgpPeeringIPAddresses (revive)
pkg/orchestrator/orchestrator.go:861:3: var-naming: var cloudABgpPeeringIpAddresses should be cloudABgpPeeringIPAddresses (revive)
pkg/orchestrator/orchestrator.go:862:3: var-naming: var cloudBBgpPeeringIpAddresses should be cloudBBgpPeeringIPAddresses (revive)
pkg/orchestrator/orchestrator.go:868: line is 157 characters (lll)
pkg/orchestrator/orchestrator.go:874:67: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
pkg/orchestrator/orchestrator.go:878: line is 157 characters (lll)
pkg/orchestrator/orchestrator.go:884:67: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
pkg/orchestrator/orchestrator.go:902:45: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
pkg/orchestrator/orchestrator.go:914:45: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
pkg/orchestrator/orchestrator.go:929: line is 131 characters (lll)
pkg/orchestrator/orchestrator.go:937:43: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:952:25: "POST" can be replaced by http.MethodPost (usestdlibvars)
pkg/orchestrator/orchestrator.go:966: line is 155 characters (lll)
pkg/orchestrator/orchestrator.go:987: line is 169 characters (lll)
pkg/orchestrator/orchestrator.go:1111:35: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:1143:38: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:1172:44: parameter name 'c' is too short for the scope of its usage (varnamelen)
pkg/orchestrator/orchestrator.go:1186: line is 135 characters (lll)
pkg/orchestrator/orchestrator.go:1207: line is 131 characters (lll)
pkg/orchestrator/orchestrator.go:1224: line is 131 characters (lll)
pkg/orchestrator/orchestrator.go:1241: line is 140 characters (lll)
pkg/orchestrator/orchestrator.go:1278:12: hugeParam: cfg is heavy (144 bytes); consider passing it by pointer (gocritic)
pkg/orchestrator/orchestrator_utils.go:21:2: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
pkg/orchestrator/orchestrator_utils.go:22:2: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
pkg/orchestrator/orchestrator_utils.go:23:2: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
pkg/orchestrator/orchestrator_utils.go:24:2: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
85 issues:
* contextcheck: 8
* gocritic: 9
* lll: 29
* nestif: 2
* revive: 21
* stylecheck: 6
* unconvert: 1
* usestdlibvars: 2
* varnamelen: 7