diff --git a/docs/code-style.md b/docs/code-style.md index 019c021cf7..679a6b07f0 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -242,8 +242,6 @@ code a lot uglier, in which case it's fine to go up to 120 or so. Whitespace guidelines: -- Put one space between keywords like `if` and `while` and their - associated open paren. - Put no space before or after the open paren for function calls and no space before the close paren for function calls. diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 27736fe94a..528cdec4c2 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -249,8 +249,10 @@ def build_custom_checkers(by_lang): 'description': 'Missing : after type in type annotation'}, {'pattern': "#type", 'description': 'Missing whitespace after "#" in type annotation'}, - {'pattern': 'if[(]', - 'description': 'Missing space between if and ('}, + {'pattern': r'\b(if|else|while)[(]', + 'description': 'Put a space between statements like if, else, etc. and (.', + 'good_lines': ['if (1 == 2):', 'while (foo == bar):'], + 'bad_lines': ['if(1 == 2):', 'while(foo == bar):']}, {'pattern': ", [)]", 'description': 'Unnecessary whitespace between "," and ")"'}, {'pattern': "% [(]",