Skip to content

Commit bcfa3bf

Browse files
committed
Add more static checks and move to separate file to match main repo
1 parent f69f1bb commit bcfa3bf

File tree

8 files changed

+223
-77
lines changed

8 files changed

+223
-77
lines changed

.clang-format

+91-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1-
# Commented out parameters are those with the same value as base LLVM style
1+
# Commented out parameters are those with the same value as base LLVM style.
22
# We can uncomment them if we want to change their value, or enforce the
3-
# chosen value in case the base style changes (last sync: Clang 6.0.1).
3+
# chosen value in case the base style changes (last sync: Clang 14.0).
44
---
55
### General config, applies to all languages ###
66
BasedOnStyle: LLVM
77
AccessModifierOffset: -4
88
AlignAfterOpenBracket: DontAlign
9-
# AlignConsecutiveAssignments: false
10-
# AlignConsecutiveDeclarations: false
9+
# AlignArrayOfStructures: None
10+
# AlignConsecutiveMacros: None
11+
# AlignConsecutiveAssignments: None
12+
# AlignConsecutiveBitFields: None
13+
# AlignConsecutiveDeclarations: None
1114
# AlignEscapedNewlines: Right
12-
# AlignOperands: true
15+
AlignOperands: DontAlign
1316
AlignTrailingComments: false
17+
# AllowAllArgumentsOnNextLine: true
1418
AllowAllParametersOfDeclarationOnNextLine: false
15-
# AllowShortBlocksOnASingleLine: false
19+
# AllowShortEnumsOnASingleLine: true
20+
# AllowShortBlocksOnASingleLine: Never
1621
# AllowShortCaseLabelsOnASingleLine: false
17-
AllowShortFunctionsOnASingleLine: Inline
18-
# AllowShortIfStatementsOnASingleLine: false
22+
# AllowShortFunctionsOnASingleLine: All
23+
# AllowShortLambdasOnASingleLine: All
24+
# AllowShortIfStatementsOnASingleLine: Never
1925
# AllowShortLoopsOnASingleLine: false
2026
# AlwaysBreakAfterDefinitionReturnType: None
2127
# AlwaysBreakAfterReturnType: None
2228
# AlwaysBreakBeforeMultilineStrings: false
23-
# AlwaysBreakTemplateDeclarations: false
29+
# AlwaysBreakTemplateDeclarations: MultiLine
30+
# AttributeMacros:
31+
# - __capability
2432
# BinPackArguments: true
2533
# BinPackParameters: true
2634
# BraceWrapping:
35+
# AfterCaseLabel: false
2736
# AfterClass: false
28-
# AfterControlStatement: false
37+
# AfterControlStatement: Never
2938
# AfterEnum: false
3039
# AfterFunction: false
3140
# AfterNamespace: false
@@ -35,32 +44,44 @@ AllowShortFunctionsOnASingleLine: Inline
3544
# AfterExternBlock: false
3645
# BeforeCatch: false
3746
# BeforeElse: false
47+
# BeforeLambdaBody: false
48+
# BeforeWhile: false
3849
# IndentBraces: false
3950
# SplitEmptyFunction: true
4051
# SplitEmptyRecord: true
4152
# SplitEmptyNamespace: true
4253
# BreakBeforeBinaryOperators: None
54+
# BreakBeforeConceptDeclarations: true
4355
# BreakBeforeBraces: Attach
4456
# BreakBeforeInheritanceComma: false
45-
BreakBeforeTernaryOperators: false
57+
# BreakInheritanceList: BeforeColon
58+
# BreakBeforeTernaryOperators: true
4659
# BreakConstructorInitializersBeforeComma: false
4760
BreakConstructorInitializers: AfterColon
4861
# BreakStringLiterals: true
4962
ColumnLimit: 0
5063
# CommentPragmas: '^ IWYU pragma:'
64+
# QualifierAlignment: Leave
5165
# CompactNamespaces: false
52-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
5366
ConstructorInitializerIndentWidth: 8
5467
ContinuationIndentWidth: 8
5568
Cpp11BracedListStyle: false
69+
# DeriveLineEnding: true
5670
# DerivePointerAlignment: false
5771
# DisableFormat: false
72+
# EmptyLineAfterAccessModifier: Never
73+
# EmptyLineBeforeAccessModifier: LogicalBlock
5874
# ExperimentalAutoDetectBinPacking: false
75+
# PackConstructorInitializers: BinPack
76+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
77+
# AllowAllConstructorInitializersOnNextLine: true
5978
# FixNamespaceComments: true
6079
# ForEachMacros:
6180
# - foreach
6281
# - Q_FOREACH
6382
# - BOOST_FOREACH
83+
# IfMacros:
84+
# - KJ_IF_MAYBE
6485
# IncludeBlocks: Preserve
6586
IncludeCategories:
6687
- Regex: '".*"'
@@ -70,13 +91,21 @@ IncludeCategories:
7091
- Regex: '^<.*'
7192
Priority: 3
7293
# IncludeIsMainRegex: '(Test)?$'
94+
# IncludeIsMainSourceRegex: ''
95+
# IndentAccessModifiers: false
7396
IndentCaseLabels: true
97+
# IndentCaseBlocks: false
98+
# IndentGotoLabels: true
7499
# IndentPPDirectives: None
100+
# IndentExternBlock: AfterExternBlock
101+
# IndentRequires: false
75102
IndentWidth: 4
76103
# IndentWrappedFunctionNames: false
104+
# InsertTrailingCommas: None
77105
# JavaScriptQuotes: Leave
78106
# JavaScriptWrapImports: true
79107
KeepEmptyLinesAtTheStartOfBlocks: false
108+
# LambdaBodyIndentation: Signature
80109
# MacroBlockBegin: ''
81110
# MacroBlockEnd: ''
82111
# MaxEmptyLinesToKeep: 1
@@ -85,39 +114,81 @@ KeepEmptyLinesAtTheStartOfBlocks: false
85114
# PenaltyBreakBeforeFirstCallParameter: 19
86115
# PenaltyBreakComment: 300
87116
# PenaltyBreakFirstLessLess: 120
117+
# PenaltyBreakOpenParenthesis: 0
88118
# PenaltyBreakString: 1000
119+
# PenaltyBreakTemplateDeclaration: 10
89120
# PenaltyExcessCharacter: 1000000
90121
# PenaltyReturnTypeOnItsOwnLine: 60
122+
# PenaltyIndentedWhitespace: 0
91123
# PointerAlignment: Right
92-
# RawStringFormats:
93-
# - Delimiter: pb
94-
# Language: TextProto
95-
# BasedOnStyle: google
124+
# PPIndentWidth: -1
125+
# ReferenceAlignment: Pointer
96126
# ReflowComments: true
97-
# SortIncludes: true
127+
# RemoveBracesLLVM: false
128+
# SeparateDefinitionBlocks: Leave
129+
# ShortNamespaceLines: 1
130+
# SortIncludes: CaseSensitive
131+
# SortJavaStaticImport: Before
98132
# SortUsingDeclarations: true
99133
# SpaceAfterCStyleCast: false
134+
# SpaceAfterLogicalNot: false
100135
# SpaceAfterTemplateKeyword: true
101136
# SpaceBeforeAssignmentOperators: true
137+
# SpaceBeforeCaseColon: false
138+
# SpaceBeforeCpp11BracedList: false
139+
# SpaceBeforeCtorInitializerColon: true
140+
# SpaceBeforeInheritanceColon: true
102141
# SpaceBeforeParens: ControlStatements
142+
# SpaceBeforeParensOptions:
143+
# AfterControlStatements: true
144+
# AfterForeachMacros: true
145+
# AfterFunctionDefinitionName: false
146+
# AfterFunctionDeclarationName: false
147+
# AfterIfMacros: true
148+
# AfterOverloadedOperator: false
149+
# BeforeNonEmptyParentheses: false
150+
# SpaceAroundPointerQualifiers: Default
151+
# SpaceBeforeRangeBasedForLoopColon: true
152+
# SpaceInEmptyBlock: false
103153
# SpaceInEmptyParentheses: false
104154
# SpacesBeforeTrailingComments: 1
105-
# SpacesInAngles: false
155+
# SpacesInAngles: Never
156+
# SpacesInConditionalStatement: false
106157
# SpacesInContainerLiterals: true
107158
# SpacesInCStyleCastParentheses: false
159+
## Godot TODO: We'll want to use a min of 1, but we need to see how to fix
160+
## our comment capitalization at the same time.
161+
SpacesInLineCommentPrefix:
162+
Minimum: 0
163+
Maximum: -1
108164
# SpacesInParentheses: false
109165
# SpacesInSquareBrackets: false
166+
# SpaceBeforeSquareBrackets: false
167+
# BitFieldColonSpacing: Both
168+
# StatementAttributeLikeMacros:
169+
# - Q_EMIT
170+
# StatementMacros:
171+
# - Q_UNUSED
172+
# - QT_REQUIRE_VERSION
110173
TabWidth: 4
174+
# UseCRLF: false
111175
UseTab: Always
176+
# WhitespaceSensitiveMacros:
177+
# - STRINGIZE
178+
# - PP_STRINGIZE
179+
# - BOOST_PP_STRINGIZE
180+
# - NS_SWIFT_NAME
181+
# - CF_SWIFT_NAME
112182
---
113183
### C++ specific config ###
114184
Language: Cpp
115-
Standard: Cpp11
185+
Standard: c++17
116186
---
117187
### ObjC specific config ###
118188
Language: ObjC
119-
Standard: Cpp11
189+
# ObjCBinPackProtocolList: Auto
120190
ObjCBlockIndentWidth: 4
191+
# ObjCBreakBeforeNestedBlockParam: true
121192
# ObjCSpaceAfterProperty: false
122193
# ObjCSpaceBeforeProtocolList: true
123194
---

.github/workflows/ci.yml

-32
Original file line numberDiff line numberDiff line change
@@ -192,35 +192,3 @@ jobs:
192192
run: |
193193
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -G"Visual Studio 16 2019" .
194194
cmake --build . --verbose
195-
196-
static-checks:
197-
name: 📊 Static Checks (clang-format)
198-
runs-on: ubuntu-20.04
199-
steps:
200-
- name: Checkout
201-
uses: actions/checkout@v3
202-
203-
- name: Make apt sources.list use the default Ubuntu repositories
204-
run: |
205-
sudo rm -f /etc/apt/sources.list.d/*
206-
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
207-
sudo apt-get update
208-
209-
- name: Install dependencies
210-
run: |
211-
sudo apt-get install -qq dos2unix recode clang-format-11
212-
sudo update-alternatives --remove-all clang-format
213-
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
214-
python -m pip install black==22.3.0
215-
216-
- name: Style checks via clang-format
217-
run: |
218-
bash ./misc/scripts/clang_format.sh
219-
220-
- name: Python style checks via black (black_format.sh)
221-
run: |
222-
bash ./misc/scripts/black_format.sh
223-
224-
- name: Bindings generation checks (ensures get_file_list returns all generated files)
225-
run: |
226-
python ./misc/scripts/check_get_file_list.py

.github/workflows/static_checks.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 📊 Static Checks
2+
on: [push, pull_request]
3+
4+
concurrency:
5+
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static
6+
cancel-in-progress: true
7+
8+
jobs:
9+
static-checks:
10+
name: Format (clang-format, black format, file format)
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
# Azure repositories are not reliable, we need to prevent Azure giving us packages.
17+
- name: Make apt sources.list use the default Ubuntu repositories
18+
run: |
19+
sudo rm -f /etc/apt/sources.list.d/*
20+
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
21+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
22+
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"
23+
sudo apt-get update
24+
25+
- name: Install dependencies
26+
run: |
27+
sudo apt-get install -qq dos2unix recode clang-format-13 libxml2-utils python3-pip moreutils
28+
sudo update-alternatives --remove-all clang-format || true
29+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100
30+
sudo pip3 install black==22.3.0 pygments pytest==7.1.2 mypy==0.971
31+
32+
- name: File formatting checks (file_format.sh)
33+
run: |
34+
bash ./misc/scripts/file_format.sh
35+
36+
- name: Header guards formatting checks (header_guards.sh)
37+
run: |
38+
bash ./misc/scripts/header_guards.sh
39+
40+
- name: Python style checks via black (black_format.sh)
41+
run: |
42+
bash ./misc/scripts/black_format.sh
43+
44+
- name: Python scripts static analysis (mypy_check.sh)
45+
run: |
46+
bash ./misc/scripts/mypy_check.sh
47+
48+
- name: Bindings generation checks (ensures get_file_list returns all generated files)
49+
run: |
50+
python ./misc/scripts/check_get_file_list.py
51+
52+
- name: Style checks via clang-format (clang_format.sh)
53+
run: |
54+
bash ./misc/scripts/clang_format.sh

misc/scripts/clang_format.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
set -uo pipefail
77

88
# Loops through all code files tracked by Git.
9-
git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \
10-
':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' |
9+
git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' |
1110
while read -r f; do
1211
# Run clang-format.
1312
clang-format --Wno-error=unknown -i "$f"

misc/scripts/file_format.sh

-23
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,6 @@ IFS=$'\n\t'
1515
# Loops through all text files tracked by Git.
1616
git grep -zIl '' |
1717
while IFS= read -rd '' f; do
18-
# Exclude some types of files.
19-
if [[ "$f" == *"csproj" ]]; then
20-
continue
21-
elif [[ "$f" == *"sln" ]]; then
22-
continue
23-
elif [[ "$f" == *".bat" ]]; then
24-
continue
25-
elif [[ "$f" == *".out" ]]; then
26-
# GDScript integration testing files.
27-
continue
28-
elif [[ "$f" == *"patch" ]]; then
29-
continue
30-
elif [[ "$f" == *"pot" ]]; then
31-
continue
32-
elif [[ "$f" == *"po" ]]; then
33-
continue
34-
elif [[ "$f" == "thirdparty"* ]]; then
35-
continue
36-
elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then
37-
continue
38-
elif [[ "$f" == *"-so_wrap."* ]]; then
39-
continue
40-
fi
4118
# Ensure that files are UTF-8 formatted.
4219
recode UTF-8 "$f" 2> /dev/null
4320
# Ensure that files have LF line endings and do not contain a BOM.

0 commit comments

Comments
 (0)