@@ -35,7 +35,6 @@ if [[ "$1" = "-install" ]]; then
35
35
# Install the pinned versions as defined in module tools.
36
36
pushd ./test/tools
37
37
go install \
38
- golang.org/x/lint/golint \
39
38
golang.org/x/tools/cmd/goimports \
40
39
honnef.co/go/tools/cmd/staticcheck \
41
40
github.com/client9/misspell/cmd/misspell
77
76
not grep ' func Test[^(]' * _test.go
78
77
not grep ' func Test[^(]' test/* .go
79
78
79
+ # - Check for typos in test function names
80
+ git grep ' func (s) ' -- " *_test.go" | not grep -v ' func (s) Test'
81
+ git grep ' func [A-Z]' -- " *_test.go" | not grep -v ' func Test\|Benchmark\|Example'
82
+
80
83
# - Do not import x/net/context.
81
84
not git grep -l ' x/net/context' -- " *.go"
82
85
@@ -94,23 +97,21 @@ git grep -l -e 'grpclog.I' --or -e 'grpclog.W' --or -e 'grpclog.E' --or -e 'grpc
94
97
not git grep " \(import \|^\s*\)\" github.com/golang/protobuf/ptypes/" -- " *.go"
95
98
96
99
# - Ensure all usages of grpc_testing package are renamed when importing.
97
- not git grep " \(import \|^\s*\)\" google.golang.org/grpc/interop/grpc_testing" -- " *.go"
100
+ not git grep " \(import \|^\s*\)\" google.golang.org/grpc/interop/grpc_testing" -- " *.go"
98
101
99
102
# - Ensure all xds proto imports are renamed to *pb or *grpc.
100
103
git grep ' "github.com/envoyproxy/go-control-plane/envoy' -- ' *.go' ' :(exclude)*.pb.go' | not grep -v ' pb "\|grpc "'
101
104
102
105
misspell -error .
103
106
104
- # - gofmt, goimports, golint (with exceptions for generated code), go vet,
105
- # go mod tidy.
107
+ # - gofmt, goimports, go vet, go mod tidy.
106
108
# Perform these checks on each module inside gRPC.
107
109
for MOD_FILE in $( find . -name ' go.mod' ) ; do
108
110
MOD_DIR=$( dirname ${MOD_FILE} )
109
111
pushd ${MOD_DIR}
110
112
go vet -all ./... | fail_on_output
111
113
gofmt -s -d -l . 2>&1 | fail_on_output
112
114
goimports -l . 2>&1 | not grep -vE " \.pb\.go"
113
- golint ./... 2>&1 | not grep -vE " /grpc_testing_not_regenerate/.*\.pb\.go:"
114
115
115
116
go mod tidy -compat=1.19
116
117
git status --porcelain 2>&1 | fail_on_output || \
@@ -119,94 +120,73 @@ for MOD_FILE in $(find . -name 'go.mod'); do
119
120
done
120
121
121
122
# - Collection of static analysis checks
122
- #
123
- # TODO(dfawley): don't use deprecated functions in examples or first-party
124
- # plugins.
125
- # TODO(dfawley): enable ST1019 (duplicate imports) but allow for protobufs.
126
123
SC_OUT=" $( mktemp) "
127
- staticcheck -go 1.19 -checks ' inherit,-ST1015,-ST1019,-SA1019' ./... > " ${SC_OUT} " || true
128
- # Error if anything other than deprecation warnings are printed.
129
- not grep -v " is deprecated:.*SA1019" " ${SC_OUT} "
130
- # Only ignore the following deprecated types/fields/functions.
131
- not grep -Fv ' .CredsBundle
132
- .HeaderMap
133
- .Metadata is deprecated: use Attributes
134
- .NewAddress
135
- .NewServiceConfig
136
- .Type is deprecated: use Attributes
137
- BuildVersion is deprecated
138
- balancer.ErrTransientFailure
139
- balancer.Picker
140
- extDesc.Filename is deprecated
141
- github.com/golang/protobuf/jsonpb is deprecated
142
- grpc.CallCustomCodec
143
- grpc.Code
144
- grpc.Compressor
145
- grpc.CustomCodec
146
- grpc.Decompressor
147
- grpc.MaxMsgSize
148
- grpc.MethodConfig
149
- grpc.NewGZIPCompressor
150
- grpc.NewGZIPDecompressor
151
- grpc.RPCCompressor
152
- grpc.RPCDecompressor
153
- grpc.ServiceConfig
154
- grpc.WithCompressor
155
- grpc.WithDecompressor
156
- grpc.WithDialer
157
- grpc.WithMaxMsgSize
158
- grpc.WithServiceConfig
159
- grpc.WithTimeout
160
- http.CloseNotifier
161
- info.SecurityVersion
162
- proto is deprecated
163
- proto.InternalMessageInfo is deprecated
164
- proto.EnumName is deprecated
165
- proto.ErrInternalBadWireType is deprecated
166
- proto.FileDescriptor is deprecated
167
- proto.Marshaler is deprecated
168
- proto.MessageType is deprecated
169
- proto.RegisterEnum is deprecated
170
- proto.RegisterFile is deprecated
171
- proto.RegisterType is deprecated
172
- proto.RegisterExtension is deprecated
173
- proto.RegisteredExtension is deprecated
174
- proto.RegisteredExtensions is deprecated
175
- proto.RegisterMapType is deprecated
176
- proto.Unmarshaler is deprecated
124
+ staticcheck -go 1.19 -checks ' all' ./... > " ${SC_OUT} " || true
125
+
126
+ # Error for anything other than checks that need exclusions.
127
+ grep -v " (ST1000)" " ${SC_OUT} " | grep -v " (SA1019)" | grep -v " (ST1003)" | not grep -v " (ST1019)\|\(other import of\)"
128
+
129
+ # Exclude underscore checks for generated code.
130
+ grep " (ST1003)" " ${SC_OUT} " | not grep -v ' \(.pb.go:\)\|\(code_string_test.go:\)'
131
+
132
+ # Error for duplicate imports not including grpc protos.
133
+ grep " (ST1019)\|\(other import of\)" " ${SC_OUT} " | not grep -Fv ' XXXXX PleaseIgnoreUnused
134
+ channelz/grpc_channelz_v1"
135
+ go-control-plane/envoy
136
+ grpclb/grpc_lb_v1"
137
+ health/grpc_health_v1"
138
+ interop/grpc_testing"
139
+ orca/v3"
140
+ proto/grpc_gcp"
141
+ proto/grpc_lookup_v1"
142
+ reflection/grpc_reflection_v1"
143
+ reflection/grpc_reflection_v1alpha"
144
+ XXXXX PleaseIgnoreUnused'
145
+
146
+ # Error for any package comments not in generated code.
147
+ grep " (ST1000)" " ${SC_OUT} " | not grep -v " \.pb\.go:"
148
+
149
+ # Only ignore the following deprecated types/fields/functions and exclude
150
+ # generated code.
151
+ grep " (SA1019)" " ${SC_OUT} " | not grep -Fv ' XXXXX PleaseIgnoreUnused
152
+ XXXXX Protobuf related deprecation errors:
153
+ "github.com/golang/protobuf
154
+ .pb.go:
155
+ : ptypes.
156
+ proto.RegisterType
157
+ XXXXX gRPC internal usage deprecation errors:
158
+ "google.golang.org/grpc
159
+ : grpc.
160
+ : v1alpha.
161
+ : v1alphareflectionpb.
162
+ BalancerAttributes is deprecated:
163
+ CredsBundle is deprecated:
164
+ Metadata is deprecated: use Attributes instead.
165
+ NewSubConn is deprecated:
166
+ OverrideServerName is deprecated:
167
+ RemoveSubConn is deprecated:
168
+ SecurityVersion is deprecated:
177
169
Target is deprecated: Use the Target field in the BuildOptions instead.
178
- xxx_messageInfo_
179
- ' " ${SC_OUT} "
180
-
181
- # - special golint on package comments.
182
- lint_package_comment_per_package () {
183
- # Number of files in this go package.
184
- fileCount=$( go list -f ' {{len .GoFiles}}' $1 )
185
- if [ ${fileCount} -eq 0 ]; then
186
- return 0
187
- fi
188
- # Number of package errors generated by golint.
189
- lintPackageCommentErrorsCount=$( golint --min_confidence 0 $1 | grep -c " should have a package comment" )
190
- # golint complains about every file that's missing the package comment. If the
191
- # number of files for this package is greater than the number of errors, there's
192
- # at least one file with package comment, good. Otherwise, fail.
193
- if [ ${fileCount} -le ${lintPackageCommentErrorsCount} ]; then
194
- echo " Package $1 (with ${fileCount} files) is missing package comment"
195
- return 1
196
- fi
197
- }
198
- lint_package_comment () {
199
- set +ex
200
-
201
- count=0
202
- for i in $( go list ./...) ; do
203
- lint_package_comment_per_package " $i "
204
- (( count += $? ))
205
- done
206
-
207
- set -ex
208
- return $count
209
- }
210
- lint_package_comment
170
+ UpdateAddresses is deprecated:
171
+ UpdateSubConnState is deprecated:
172
+ balancer.ErrTransientFailure is deprecated:
173
+ grpc/reflection/v1alpha/reflection.proto
174
+ XXXXX xDS deprecated fields we support
175
+ .ExactMatch
176
+ .PrefixMatch
177
+ .SafeRegexMatch
178
+ .SuffixMatch
179
+ GetContainsMatch
180
+ GetExactMatch
181
+ GetMatchSubjectAltNames
182
+ GetPrefixMatch
183
+ GetSafeRegexMatch
184
+ GetSuffixMatch
185
+ GetTlsCertificateCertificateProviderInstance
186
+ GetValidationContextCertificateProviderInstance
187
+ XXXXX TODO: Remove the below deprecation usages:
188
+ CloseNotifier
189
+ Roots.Subjects
190
+ XXXXX PleaseIgnoreUnused'
211
191
212
192
echo SUCCESS
0 commit comments