Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Commit

Permalink
Hermetic set of linters (#1365)
Browse files Browse the repository at this point in the history
* Hermetic linter config

Don't automatically add new linters. Linters must be explicitly  added

* Enable whitespace linter

* Update golangci-lint to 1.19
  • Loading branch information
gdbelvin committed Oct 7, 2019
1 parent 470db41 commit 7526357
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 27 deletions.
35 changes: 25 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
service:
golangci-lint-version: 1.18.x
golangci-lint-version: 1.19.x

run:
timeout: 5m
Expand All @@ -26,15 +26,30 @@ linters-settings:
- github.com/google/martian/log

linters:
enable-all: true
disable:
- maligned
- scopelint
- gochecknoinits
- gochecknoglobals
- lll
- interfacer
- funlen
enable:
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gosec
- ineffassign
- misspell
- nakedret
- prealloc
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace

issues:
exclude:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: "build"
script: go build ./...
- name: "lint"
install: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.18.0
install: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.19.0
script: golangci-lint run --deadline=7m
- name: "coverage"
script:
Expand Down
1 change: 0 additions & 1 deletion cmd/keytransparency-client/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func initConfig() {
fmt.Println("Using config file:", viper.ConfigFileUsed())
}
}

}

// getTokenFromWeb uses config to request a Token. Returns the retrieved Token.
Expand Down
1 change: 0 additions & 1 deletion cmd/serverutil/serverutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type RegisterServiceFromEndpoint func(context.Context, *runtime.ServeMux, string
// GrpcGatewayMux registers multiple gRPC services with a gRPC ServeMux
func GrpcGatewayMux(ctx context.Context, addr string, dopts []grpc.DialOption,
services ...RegisterServiceFromEndpoint) (*runtime.ServeMux, error) {

gwmux := runtime.NewServeMux()
for _, s := range services {
if err := s(ctx, gwmux, addr, dopts); err != nil {
Expand Down
1 change: 0 additions & 1 deletion core/adminserver/admin_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func TestDelete(t *testing.T) {
if got, want := status.Code(err), codes.NotFound; got != want {
t.Fatalf("GetDirectory(): %v, want %v", got, want)
}

}
}

Expand Down
1 change: 0 additions & 1 deletion core/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func TestPaginateHistory(t *testing.T) {
t.Errorf("PaginateHistory().values: \n%#v, want \n%#v, diff: \n%v",
got, want, pretty.Compare(got, want))
}

})
}
}
Expand Down
2 changes: 0 additions & 2 deletions core/client/gobindclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func GetUser(ktURL, userID string) ([]byte, error) {
}

func dial(ktURL string, insecureTLS bool, ktTLSCertPEM []byte) (*grpc.ClientConn, error) {

creds, err := transportCreds(ktURL, insecureTLS, ktTLSCertPEM)
if err != nil {
return nil, err
Expand All @@ -153,7 +152,6 @@ func dial(ktURL string, insecureTLS bool, ktTLSCertPEM []byte) (*grpc.ClientConn
}

func transportCreds(ktURL string, insecure bool, ktTLSCertPEM []byte) (credentials.TransportCredentials, error) {

host, _, err := net.SplitHostPort(ktURL)
if err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion core/crypto/vrf/p256/p256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func BenchmarkEvaluate(b *testing.B) {
}
})
}

}

// Test vectors in core/testdata are generated by running
Expand Down
1 change: 0 additions & 1 deletion core/crypto/vrf/p256/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int) {
// Use the curve equation to calculate y² given x.
// only applies to curves of the form y² = x³ - 3x + b.
func y2(curve *elliptic.CurveParams, x *big.Int) *big.Int {

// y² = x³ - 3x + b
x3 := new(big.Int).Mul(x, x)
x3.Mul(x3, x)
Expand Down
3 changes: 0 additions & 3 deletions core/keyserver/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (s *Server) GetRevision(ctx context.Context, in *pb.GetRevisionRequest) (*p
}

return s.getRevisionByRevision(ctx, d, logRoot, logConsistency, in.GetRevision())

}

func (s *Server) getRevisionByRevision(ctx context.Context, d *directory.Directory,
Expand Down Expand Up @@ -177,7 +176,6 @@ func (s *Server) ListMutations(ctx context.Context, in *pb.ListMutationsRequest)
nextToken, err := EncodeToken(SourceList(meta.Sources).Next(rt, lastRow))
if st := status.Convert(err); st.Code() != codes.OK {
return nil, status.Errorf(st.Code(), "Failed creating next token: %v", st.Message())

}
return &pb.ListMutationsResponse{
Mutations: mutations,
Expand Down Expand Up @@ -215,7 +213,6 @@ func (s *Server) logInclusion(ctx context.Context, d *directory.Directory, logRo
return nil, status.Errorf(st.Code(), "Cannot fetch log inclusion proof: %v", st.Message())
}
return logInclusion.GetProof(), nil

}

func (s *Server) latestLogRootProof(ctx context.Context, d *directory.Directory, firstTreeSize int64) (
Expand Down
1 change: 0 additions & 1 deletion core/sequencer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ func (s *Server) ApplyRevisions(ctx context.Context, in *spb.ApplyRevisionsReque
func (s *Server) readMessages(ctx context.Context, source *spb.MapMetadata_SourceSlice,
directoryID string, chunkSize int32,
emit func(*mutator.LogMessage)) error {

low := source.LowestInclusive
high := source.HighestExclusive
// Loop until less than chunkSize items are returned.
Expand Down
2 changes: 0 additions & 2 deletions core/sequencer/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (l fakeLogs) ReadLog(ctx context.Context, directoryID string, logID, low, h
refs = append(refs, &l[logID][i])
}
return refs, nil

}

func (l fakeLogs) ListLogs(ctx context.Context, directoryID string, writable bool) ([]int64, error) {
Expand Down Expand Up @@ -199,7 +198,6 @@ func TestDefiningRevisions(t *testing.T) {
}
})
}

}

func TestReadMessages(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion impl/authorization/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (a *AuthzPolicy) Authorize(ctx context.Context, m interface{}) error {
default:
return status.Errorf(codes.PermissionDenied, "message type %T not recognized", t)
}

}

func (a *AuthzPolicy) checkPermission(sctx *authentication.SecurityContext, directoryID, userID string) error {
Expand Down
1 change: 0 additions & 1 deletion impl/authorization/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func UnaryServerInterceptor(authFuncs map[string]AuthPair) grpc.UnaryServerInter
glog.V(2).Infof("auth interceptor: no handler for %v", info.FullMethod)
// If no auth handler was found for this method, invoke the method directly.
return handler(ctx, req)

}
newCtx, err := policy.AuthnFunc(ctx)
if err != nil {
Expand Down

0 comments on commit 7526357

Please sign in to comment.