Commit d474751
authored
Created coding-standard.py to check whitespace/formatting of plain text files (#981)
Created coding-standard.py to check whitespace/formatting of plain text files.
The Python script will check text files to make sure they don't have
any tab characters (except Makefiles) and they don't have trailing
whitespace. I made it smarter than the sample pre-commit hook: it
*only checks the files that are being changed*, not the entire
repo. This way there's no huge commit just to update whitespace.
It's also able to do double duty as a PR check. Same thing, it only
checks the files in the PR, not the entire repo. If there's any bad
whitespace then it blocks the PR from being committed.
I've *also* added checking of the C formatting to the
tool. **HOWEVER** it will only check the C++ coding style **IFF** the
previous version of the file in the repo *already* conforms to the
standard as specified by the `.clang-format` file. I suspect there
aren't many files that already conform, if there are any at all, so
it's unlikely anyone will run into complaints about an edited file not
having proper formatting. A brand new file *will* be expected to
conform though. I made a couple of minor changes to the
`.clang-format`: no tab characters, and lines should be less than 96
characters long.
Two other features are `--fix` which will automatically make the
necessary corrections to only the files listed on the command line;
and `--show` that reformats the specified file and prints it to
stdout.1 parent 329f3e4 commit d474751
File tree
5 files changed
+502
-4
lines changed- .github/workflows
5 files changed
+502
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments