Skip to content

Commit 7aec2fb

Browse files
committed
Fix arc lint errors from gci modifications (more outstanding issues brought into scope). Remove goimports from arc since it conflicts with gci
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 4810b98 commit 7aec2fb

18 files changed

Lines changed: 72 additions & 76 deletions

File tree

.arclint

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@
127127
"script-and-regex.script": "./tools/linters/gazelle.sh",
128128
"script-and-regex.regex": "/^(?P<severity>[[:alpha:]]+)\n(?P<file>[^\n]+)\n(?P<message>[^\n]+)\n((?P<line>\\d),(?P<char>\\d)\n<<<<<\n(?P<original>.*)=====\n(?P<replacement>.*)>>>>>\n)$/s"
129129
},
130-
"goimports": {
131-
"type": "goimports",
132-
"include": [
133-
"(\\.go$)"
134-
]
135-
},
136130
"golangci-lint": {
137131
"type": "golangci-lint",
138132
"include": [

src/cloud/api/controllers/session_middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func getAugmentedToken(env apienv.APIEnv, r *http.Request) (string, error) {
170170

171171
// If the header "X-Use-Bearer is true we force the use of Bearer auth and ignore sessions.
172172
// This is needed to prevent logged in pixie sessions to show up in embedded versions.
173-
forceBearer := false
173+
forceBearer := false //nolint:staticcheck
174174
if strings.ToLower(r.Header.Get("X-Use-Bearer")) == "true" {
175175
forceBearer = true
176176
}

src/cloud/artifact_tracker/controllers/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (s *Server) GetDownloadLink(ctx context.Context, in *apb.GetDownloadLinkReq
173173
return nil, status.Error(codes.InvalidArgument, "artifact type cannot be unknown")
174174
}
175175

176-
if !(at == vpb.AT_DARWIN_AMD64 || at == vpb.AT_LINUX_AMD64 || at == vpb.AT_CONTAINER_SET_YAMLS || at == vpb.AT_CONTAINER_SET_TEMPLATE_YAMLS) {
176+
if at != vpb.AT_CONTAINER_SET_LINUX_AMD64 && at != vpb.AT_CONTAINER_SET_YAMLS && at != vpb.AT_CONTAINER_SET_TEMPLATE_YAMLS {
177177
return nil, status.Error(codes.InvalidArgument, "artifact type cannot be downloaded")
178178
}
179179

src/cloud/autocomplete/suggester.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ func (e *ElasticSuggester) GetSuggestions(reqs []*SuggestionRequest) ([]*Suggest
172172
scriptArgMap[s.ScriptName] = make([]cloudpb.AutocompleteEntityKind, 0)
173173
for _, a := range s.Vis.Variables {
174174
aKind := cloudpb.AEK_UNKNOWN
175-
if a.Type == vispb.PX_POD {
175+
switch a.Type {
176+
case vispb.PX_POD:
176177
aKind = cloudpb.AEK_POD
177-
} else if a.Type == vispb.PX_SERVICE {
178+
case vispb.PX_SERVICE:
178179
aKind = cloudpb.AEK_SVC
179180
}
180181

@@ -272,7 +273,7 @@ func (e *ElasticSuggester) GetSuggestions(reqs []*SuggestionRequest) ([]*Suggest
272273
// TODO(michellenguyen): Remove namespace handling when we create a new index and ensure there are no more
273274
// documents with namespace.
274275
resName := res.Name
275-
if res.NS != "" && !(md.EsMDType(res.Kind) == md.EsMDTypeNamespace || md.EsMDType(res.Kind) == md.EsMDTypeNode) {
276+
if res.NS != "" && !(md.EsMDType(res.Kind) == md.EsMDTypeNamespace || md.EsMDType(res.Kind) == md.EsMDTypeNode) { //nolint:staticcheck
276277
resName = fmt.Sprintf("%s/%s", res.NS, res.Name)
277278
}
278279

src/cloud/plugin/controllers/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ func (s *Server) UpdateOrgRetentionPluginConfig(ctx context.Context, req *plugin
560560
if req.Version != nil {
561561
version = req.Version.Value
562562
}
563-
if req.Configurations != nil && len(req.Configurations) > 0 {
563+
if len(req.Configurations) > 0 {
564564
configurations, _ = json.Marshal(req.Configurations)
565565
}
566566

src/cloud/profile/controllers/server.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@ func orgInfoToProto(o *datastore.OrgInfo) *profilepb.OrgInfo {
167167
}
168168

169169
func toExternalError(err error) error {
170-
if err == datastore.ErrOrgNotFound {
170+
switch err {
171+
case datastore.ErrOrgNotFound:
171172
return status.Error(codes.NotFound, "no such org")
172-
} else if err == datastore.ErrUserNotFound {
173+
case datastore.ErrUserNotFound:
173174
return status.Error(codes.NotFound, "no such user")
175+
default:
176+
return err
174177
}
175-
return err
176178
}
177179

178180
// CreateUser is the GRPC method to create new user.

src/cloud/project_manager/datastore/datastore_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"testing"
2525

2626
"github.com/gofrs/uuid"
27-
_ "github.com/golang-migrate/migrate/source/go_bindata"
28-
bindata "github.com/golang-migrate/migrate/source/go_bindata"
27+
_ "github.com/golang-migrate/migrate/source/go_bindata" //nolint:staticcheck
28+
bindata "github.com/golang-migrate/migrate/source/go_bindata" //nolint:staticcheck
2929
_ "github.com/jackc/pgx/stdlib"
3030
"github.com/jmoiron/sqlx"
3131
"github.com/stretchr/testify/assert"

src/cloud/shared/idprovider/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ func (c *HydraKratosClient) HandleLogin(session *sessions.Session, w http.Respon
531531
// Copy the header because the header contains a necessary Set-Cookie from the OAuth server.
532532
for k, vv := range respHeader {
533533
// We only want to cookie and Location headers, otherwise Firefox and Safari complain.
534-
if !(k == "Set-Cookie" || k == "Location") {
534+
if k != "Set-Cookie" && k != "Location" {
535535
continue
536536
}
537537
for _, v := range vv {

src/cloud/shared/idprovider/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func makeClientFromConfig(t *testing.T, p *testClientConfig) (*HydraKratosClient
9494
assert.Equal(t, "abcd", r.Header.Get("ory_hydra_session"))
9595
// The actual endpoint sets a cookie, so we want do forward that as well.
9696
w.Header().Set("Set-Cookie", p.hydraPublicHostCookie)
97-
http.Redirect(w, r, consentURL.String(), 302)
97+
http.Redirect(w, r, consentURL.String(), http.StatusFound)
9898
}))
9999

100100
acceptConsentRequestFn := func(params *hydraAdmin.AcceptConsentRequestParams) (*hydraAdmin.AcceptConsentRequestOK, error) {

src/common/testing/test_utils/cert_generator/cert_generator.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ func generateAndWriteCertPair(ca *x509.Certificate, caKey *rsa.PrivateKey, certP
115115
}
116116

117117
keyType := viper.GetString("secret_key_type")
118-
if keyType == "pkcs1" {
118+
switch keyType {
119+
case "pkcs1":
120+
119121
err = pem.Encode(keyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(privateKey)})
120122
if err != nil {
121123
panic(err)
122124
}
123-
} else if keyType == "pkcs8" {
125+
case "pkcs8":
124126
b, err := x509.MarshalPKCS8PrivateKey(privateKey)
125127
if err != nil {
126128
panic(err)
@@ -130,7 +132,7 @@ func generateAndWriteCertPair(ca *x509.Certificate, caKey *rsa.PrivateKey, certP
130132
if err != nil {
131133
panic(err)
132134
}
133-
} else {
135+
default:
134136
panic(fmt.Sprintf("Unsupported private key type: %s", keyType))
135137
}
136138
err = keyOut.Close()

0 commit comments

Comments
 (0)