Skip to content
Permalink
Browse files

Hermetic set of linters (#1365)

* 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 752635792d44ebb04b5ff277d305c698d47d2536
@@ -1,5 +1,5 @@
service:
golangci-lint-version: 1.18.x
golangci-lint-version: 1.19.x

run:
timeout: 5m
@@ -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:
@@ -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:
@@ -115,7 +115,6 @@ func initConfig() {
fmt.Println("Using config file:", viper.ConfigFileUsed())
}
}

}

// getTokenFromWeb uses config to request a Token. Returns the retrieved Token.
@@ -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 {
@@ -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)
}

}
}

@@ -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))
}

})
}
}
@@ -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
@@ -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
@@ -200,7 +200,6 @@ func BenchmarkEvaluate(b *testing.B) {
}
})
}

}

// Test vectors in core/testdata are generated by running
@@ -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)
@@ -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,
@@ -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,
@@ -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) (
@@ -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.
@@ -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) {
@@ -199,7 +198,6 @@ func TestDefiningRevisions(t *testing.T) {
}
})
}

}

func TestReadMessages(t *testing.T) {
@@ -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 {
@@ -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 {

0 comments on commit 7526357

Please sign in to comment.
You can’t perform that action at this time.