diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-18 14:57:23 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-18 14:57:23 +0100 |
commit | 7f2280a580f82e5eb248dc668ccb7d713b3e82ff (patch) | |
tree | 1d0cef2b2725094fe7f8741cde359360489e7fa2 | |
parent | 0400859ae22d650c495358d0bc1da5014da94c5c (diff) | |
download | psutil-7f2280a580f82e5eb248dc668ccb7d713b3e82ff.tar.gz |
check missing space between keyword and parenthesis
-rw-r--r-- | psutil/arch/windows/net.c | 2 | ||||
-rwxr-xr-x | scripts/internal/clinter.py | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/psutil/arch/windows/net.c b/psutil/arch/windows/net.c index f0572d52..56c6b6f1 100644 --- a/psutil/arch/windows/net.c +++ b/psutil/arch/windows/net.c @@ -401,7 +401,7 @@ psutil_net_if_stats(PyObject *self, PyObject *args) { } // is up? - if((pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED || + if ((pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED || pIfRow->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL) && pIfRow->dwAdminStatus == 1 ) { py_is_up = Py_True; diff --git a/scripts/internal/clinter.py b/scripts/internal/clinter.py index 695729b7..6e880589 100755 --- a/scripts/internal/clinter.py +++ b/scripts/internal/clinter.py @@ -39,10 +39,17 @@ def check_line(path, line, idx, lines): nextline.strip()[0] != '#' and \ nextline.strip()[:2] != '*/': warn(path, line, lineno, "expected 1 blank line") - # minus initial white spaces - s = s.lstrip() - if s.startswith('//') and s[2] != ' ' and line.strip() != '//': + + sls = s.lstrip() + if sls.startswith('//') and sls[2] != ' ' and line.strip() != '//': warn(path, line, lineno, "no space after // comment") + + # e.g. "if(..." after keywords + keywords = ("if", "else", "while", "do", "enum", "for") + for kw in keywords: + if sls.startswith(kw + '('): + warn(path, line, lineno, "missing space between %r and '('" % kw) + # eof if eof: if not line.endswith('\n'): warn(path, line, lineno, "no blank line at EOF") |