Tighten the bar and refactor and offender:

pull/15680/head
ncteisen 7 years ago
parent 2ce76b33e3
commit eb2aa9cb3b
  1. 6
      .clang-tidy
  2. 25
      test/core/transport/status_conversion_test.cc
  3. 9
      tools/distrib/run_clang_tidy.py

@ -0,0 +1,6 @@
---
Checks: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size'
WarningsAsErrors: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size'
CheckOptions:
- key: readability-function-size.StatementThreshold
value: '450'

@ -33,12 +33,7 @@
#define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \
GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b))
int main(int argc, char** argv) {
int i;
grpc_test_init(argc, argv);
grpc_init();
static void test_grpc_status_to_http2_error() {
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_HTTP2_INTERNAL_ERROR);
@ -65,7 +60,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAVAILABLE,
GRPC_HTTP2_REFUSED_STREAM);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_HTTP2_INTERNAL_ERROR);
}
static void test_grpc_status_to_http2_status() {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_OK, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_CANCELLED, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNKNOWN, 200);
@ -83,7 +80,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_INTERNAL, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200);
}
static void test_http2_error_to_grpc_status() {
const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE;
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline,
GRPC_STATUS_INTERNAL);
@ -144,7 +143,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_RESOURCE_EXHAUSTED);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, after_deadline,
GRPC_STATUS_PERMISSION_DENIED);
}
static void test_http2_status_to_grpc_status() {
HTTP2_STATUS_TO_GRPC_STATUS(200, GRPC_STATUS_OK);
HTTP2_STATUS_TO_GRPC_STATUS(400, GRPC_STATUS_INVALID_ARGUMENT);
HTTP2_STATUS_TO_GRPC_STATUS(401, GRPC_STATUS_UNAUTHENTICATED);
@ -157,6 +158,18 @@ int main(int argc, char** argv) {
HTTP2_STATUS_TO_GRPC_STATUS(500, GRPC_STATUS_UNKNOWN);
HTTP2_STATUS_TO_GRPC_STATUS(503, GRPC_STATUS_UNAVAILABLE);
HTTP2_STATUS_TO_GRPC_STATUS(504, GRPC_STATUS_DEADLINE_EXCEEDED);
}
int main(int argc, char** argv) {
int i;
grpc_test_init(argc, argv);
grpc_init();
test_grpc_status_to_http2_error();
test_grpc_status_to_http2_status();
test_http2_error_to_grpc_status();
test_http2_status_to_grpc_status();
/* check all status values can be converted */
for (i = 0; i <= 999; i++) {

@ -24,13 +24,6 @@ sys.path.append(
os.path.dirname(sys.argv[0]), '..', 'run_tests', 'python_utils'))
import jobset
GRPC_CHECKS = [
'modernize-use-nullptr',
'google-build-namespaces',
'google-build-explicit-make-pair',
'readability-function-size',
]
extra_args = [
'-x',
'c++',
@ -58,8 +51,6 @@ args = argp.parse_args()
cmdline = [
clang_tidy,
'--checks=-*,%s' % ','.join(GRPC_CHECKS),
'--warnings-as-errors=%s' % ','.join(GRPC_CHECKS)
] + ['--extra-arg-before=%s' % arg for arg in extra_args]
if args.fix:

Loading…
Cancel
Save