Skip to content

Commit

Permalink
Enable first basic linters in ARO (#2060)
Browse files Browse the repository at this point in the history
* Enable first basic linters in ARO

* Remove modules-download-mode from the linter run config
  • Loading branch information
devamanv authored Apr 19, 2022
1 parent a766527 commit 5a7e281
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
run:
timeout: 5m
skip-dirs:
- vendor/portal

issues:
exclude-rules:
- linters:
- staticcheck
text: "SA1019: codec.BasicHandle is deprecated"
# This is set to false to disregard the default EXC0011 exclusion
# which shadows all the ST* checks. Refer https://github.com/golangci/golangci-lint/issues/2281
exclude-use-default: false

linters-settings:
gofmt:
simplify: false

stylecheck:
# added additional checks for comments in Go.
# Refer https://staticcheck.io/docs/options#checks for details
checks: ["all", "-ST1000", "ST1020", "ST1021", "ST1022"]


linters:
disable-all: true
enable:
- gofmt
- unused
- deadcode
- gosimple
- govet
- staticcheck
# TODO: Enable the stylecheck linter in a follow-up PR as it requires changes in a lot of files
# - stylecheck
- whitespace

1 change: 0 additions & 1 deletion pkg/env/armhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func newARMHelper(ctx context.Context, log *logrus.Entry, env Interface) (ARMHel
if err != nil {
return nil, err
}

} else {
key, certs, err := env.ServiceKeyvault().GetCertificateSecret(ctx, RPDevARMSecretName)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/env/prod.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ func newProd(ctx context.Context, log *logrus.Entry) (*prod, error) {
func (p *prod) InitializeAuthorizers() error {
if !p.FeatureIsSet(FeatureEnableDevelopmentAuthorizer) {
p.armClientAuthorizer = clientauthorizer.NewARM(p.log, p.Core)

} else {
armClientAuthorizer, err := clientauthorizer.NewSubjectNameAndIssuer(
p.log,
Expand Down
1 change: 0 additions & 1 deletion pkg/proxy/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,4 @@ func NewDialer(isLocalDevelopmentMode bool) (Dialer, error) {
}

return d, nil

}
2 changes: 0 additions & 2 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func (s Server) proxyHandler(w http.ResponseWriter, r *http.Request) {
// validateProxyRequest checks that the request is valid. If not, it writes the
// appropriate http headers and returns an error.
func (s Server) validateProxyRequest(w http.ResponseWriter, r *http.Request) error {

ip, _, err := net.SplitHostPort(r.Host)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
Expand Down Expand Up @@ -183,5 +182,4 @@ func Proxy(log *logrus.Entry, w http.ResponseWriter, r *http.Request, sz int) {
_ = c1.(interface{ CloseWrite() error }).CloseWrite()
}()
_, _ = io.Copy(c1, c2)

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (c *virtualMachineScaleSetsClient) List(ctx context.Context, resourceGroupN
if err != nil {
return nil, err
}

}
return scaleSets, nil
}
1 change: 0 additions & 1 deletion pkg/util/computeskus/computeskus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func TestFilterVmSizes(t *testing.T) {
},
} {
t.Run(tt.name, func(t *testing.T) {

sku := []mgmtcompute.ResourceSku{
{
Name: to.StringPtr("Fake_Sku"),
Expand Down
1 change: 0 additions & 1 deletion pkg/util/instancemetadata/prodfromenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func newProdFromEnv(ctx context.Context) (InstanceMetadata, error) {
}

func (p *prodFromEnv) populateInstanceMetadata() error {

for _, key := range []string{
"AZURE_ENVIRONMENT",
"AZURE_SUBSCRIPTION_ID",
Expand Down
1 change: 0 additions & 1 deletion pkg/util/recover/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func Panic(log *logrus.Entry) {
if log != nil {
log.Error(e)
log.Info(string(debug.Stack()))

} else {
fmt.Fprintln(os.Stderr, e)
debug.PrintStack()
Expand Down

0 comments on commit 5a7e281

Please sign in to comment.