Repository: pandas-dev/pandas
Pull request: DOC: exclude autogenerated c/cpp/html files from 'trailing whitespace' checks
- [x] closes #24526 
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Problem statement:
DOC: code_checks patterns does not ignore .c files
should ignore .c files that are generated from .pyx (which are most)

get a bunch of errors like this

```
....
pandas/_libs/tslib.c:32200:Tailing whitespaces found:  * 
pandas/_libs/tslib.c:32201:Tailing whitespaces found:  * 
pandas/_libs/tslib.c:32211:Tailing whitespaces found:  * 
pandas/_libs/tslib.c:32213:Tailing whitespaces found:  * 
pandas/_libs/tslib.c:32214:Tailing whitespaces found:  * 
pandas/_libs/tslib.c:33594:Tailing whitespaces found:         
pandas/_libs/tslib.c:33595:Tailing whitespaces found:         
pandas/_libs/tslib.c:34701:Tailing whitespaces found:         
pandas/_libs/tslib.c:34702:Tailing whitespaces found:         
pandas/_libs/algos_take_helper.pxi:289:Tailing whitespaces found:     
pandas/_libs/algos_take_helper.pxi:324:Tailing whitespaces found:     
pandas/_libs/algos_take_helper.pxi:549:Tailing whitespaces found:     
pandas/_libs/algos_take_helper.pxi:584:Tailing whitespaces found:     
pandas/_libs/algos_take_helper.pxi:4709:Tailing whitespaces found:     
pandas/_libs/algos_take_helper.pxi:4744:Tailing whitespaces found:     
pandas.egg-info/PKG-INFO:10:Tailing whitespaces found: Description
pandas.egg-info/PKG-INFO:19:Tailing whitespaces found:         
pandas.egg-info/PKG-INFO:21:Tailing whitespaces found:         
pandas.egg-info/PKG-INFO:29:Tailing whitespaces found:         
pandas.egg-info/PKG-INFO:37:Tailing whitespaces found:         
pandas.egg-info/PKG-INFO:39:Tailing whitespaces found:         
pandas.egg-info/PKG-INFO:65:Tailing whitespaces found:         
pandas.egg-info/PKG-INFO:72:Tailing whitespaces found:         
Check that no file in the repo contains tailing whitespaces DONE
```

Hints from issue discussion:
@jreback - I will give this a shot. 
@jreback - this error is generated from a section that `Check that no file in the repo contains tailing whitespaces` . Adding a exclusion for c (and cpp) files will  prevent this errors for all c/cpp files in the repo and not just those generated from .pyx files. However,  c/cpp files inside `pandas/_libs`  are linted in another test. I believe adding exception should be okay.

Commit message: Added comment on c/cpp

Patch to review:
diff --git a/ci/code_checks.sh b/ci/code_checks.sh
index d16249724127f..46feed6d3039b 100755
--- a/ci/code_checks.sh
+++ b/ci/code_checks.sh
@@ -93,7 +93,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
     # this particular codebase (e.g. src/headers, src/klib, src/msgpack). However,
     # we can lint all header files since they aren't "generated" like C files are.
     MSG='Linting .c and .h' ; echo $MSG
-    cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime
+    cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime /pandas/io/msgpack /pandas/_libs/*.cpp /pandas/util
     RET=$(($RET + $?)) ; echo $MSG "DONE"
 
     echo "isort --version-number"
@@ -174,9 +174,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
     MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG
     set -o pipefail
     if [[ "$AZURE" == "true" ]]; then
-        ! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
+        # we exclude all c/cpp files as the c/cpp files of pandas code base are tested when Linting .c and .h files
+        ! grep -n '--exclude=*.'{svg,c,cpp,html} -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
     else
-        ! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
+        ! grep -n '--exclude=*.'{svg,c,cpp,html}  -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
     fi
     RET=$(($RET + $?)) ; echo $MSG "DONE"
 fi


Code review comments:
diff_hunk: @@ -93,7 +93,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
     # this particular codebase (e.g. src/headers, src/klib, src/msgpack). However,
     # we can lint all header files since they aren't "generated" like C files are.
     MSG='Linting .c and .h' ; echo $MSG
-    cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime
+    cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime /pandas/io/msgpack /pandas/_libs/*.cpp /pandas/util
path: ci/code_checks.sh
text: @user1:
why do these have leading slashes? (and nothing else does)

@author:
my bad.