This repository was archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
47 lines (40 loc) · 1.63 KB
/
code_guidelines.yml
File metadata and controls
47 lines (40 loc) · 1.63 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# GitHub Action that verifies C++ source compliance with cpplint
name: Code Guidelines
on: [push, pull_request]
jobs:
cpplint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- run: python -m pip install cpplint
- name: cpplint
shell: python
run: |
import os
import re
import subprocess
import sys
import glob
print("Python {}.{}.{}".format(*sys.version_info))
print("cpplint:")
result = subprocess.run(["cpplint", "--filter=-build/include_subdir,-build/c++11", "--linelength=120", "--root=src", "--recursive", "src"], text=True)
if result.returncode:
sys.exit(result.returncode)
source_files = glob.glob('src/**/*.*', recursive=True)
cpp_exts = tuple(".c .c++ .cc .cpp .cu .cuh .cxx .h .h++ .hh .hpp .hxx".split())
cpp_files = [file for file in source_files if file.lower().endswith(cpp_exts)]
print(f"{len(cpp_files)} C++ files were found.")
upper_files = [file for file in cpp_files if file != file.lower()]
if upper_files:
print(f"{len(upper_files)} files contain uppercase characters:")
print("\n".join(upper_files) + "\n")
space_files = [file for file in cpp_files if " " in file]
if space_files:
print(f"{len(space_files)} files contain space character:")
print("\n".join(space_files) + "\n")
bad_files = len(space_files)
if bad_files:
sys.exit(bad_files)