Skip to content

Commit 27922ec

Browse files
gmarullnschonniclaude
committed
treewide: tighten clang-format config and enforce it in CI
Keep the Google preset as the base and only list deviations. Compared to the previous config, all the "short X on a single line" options are disabled so functions, enums, ifs and loops always span multiple lines, braced lists always break after the opening brace, call arguments are not allowed to be moved as a whole to the next line, and consecutive macro definitions are aligned so register maps and lookup tables stay readable. String literals are never split so log and i18n messages remain greppable. Braced initializer members are indented by two columns and trailing comments are separated by a single space, matching the prevailing style of the existing sources. Options that are already Google defaults (IndentWidth, UseTab) are dropped. BreakAfterOpenBracketBracedList/BreakBeforeCloseBracketBracedList require clang-format 22, which is what the CI action runs. Template sources, generated bitmap data headers, the clar test framework and the test fixtures are excluded from formatting via .clang-format-ignore. The fixtures are captured data that some tests parse as text at runtime, so their layout must not change. Co-authored-by: Nick Schonning <nschonni@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
1 parent 061a317 commit 27922ec

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

.clang-format

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
---
22
BasedOnStyle: Google
3-
IndentWidth: 2
4-
UseTab: Never
5-
PointerAlignment: Right
63
ColumnLimit: 100
4+
PointerAlignment: Right
75
SortIncludes: Never
8-
AllowShortFunctionsOnASingleLine: Empty
9-
---
6+
AllowAllArgumentsOnNextLine: false
7+
AllowShortEnumsOnASingleLine: false
8+
AllowShortFunctionsOnASingleLine: None
9+
AllowShortIfStatementsOnASingleLine: Never
10+
AllowShortLoopsOnASingleLine: false
11+
BreakAfterOpenBracketBracedList: true
12+
BreakBeforeCloseBracketBracedList: true
13+
AlignConsecutiveMacros: Consecutive
14+
BreakStringLiterals: false
15+
BracedInitializerIndentWidth: 2
16+
SpacesBeforeTrailingComments: 1

.clang-format-ignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**/*.template.c
2+
**/*.template.h
3+
apps/samples/fps_test/src/test_bitmaps.h
4+
sdk/defaults/lib/lib.c
5+
sdk/defaults/lib/lib.h
6+
src/fw/apps/demo/demo_images/*
7+
src/fw/apps/demo/fps_test_bitmaps.h
8+
tools/clar/*
9+
tests/fixtures/**

.github/workflows/compliance.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,19 @@ jobs:
101101
echo " /* SPDX-License-Identifier: Apache-2.0 */"
102102
exit 1
103103
fi
104+
105+
clang-format:
106+
runs-on: ubuntu-24.04
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v7
110+
with:
111+
fetch-depth: 0
112+
113+
- name: Rebase onto target branch
114+
uses: ./.github/actions/rebase
115+
116+
- name: Run clang-format
117+
uses: jidicula/clang-format-action@v4.18.0
118+
with:
119+
clang-format-version: "22"

0 commit comments

Comments
 (0)