quality: add code-style + CGAL-convention checkers (local-only)
Closes the gap "no code-quality / convention gate" from the structural
review. Three new artefacts, all local-only (CI promotion deferred
until the existing tree is 100 % clean under each):
1. .clang-format — project's existing style mechanically captured
(4-space indent, opening brace on new line for class/struct/function,
left-aligned pointer/reference modifiers, aligned `using = ...` blocks,
100-col loose limit, no include re-ordering — matches code/include/
today).
2. scripts/quality/clang-format.sh — drift detector. Dry-run mode by
default (always exits 0); --strict to fail on drift; --fix to apply
suggested changes in place. Skips code/deps/ and macOS-duplicate
files.
3. scripts/quality/cgal-conventions.py — checker for the CGAL idioms
that clang-format/clang-tidy cannot express:
CGAL-1 include-guard format `CGAL_<DIRS>_<FILE>_H`
CGAL-2 every public header has a `\\file` Doxygen brief
CGAL-3 no nested namespaces beyond the allowed set
(CGAL::parameters, CGAL::Conformal_map, internal_np, IO)
CGAL-4 named-parameter tag types end in `_t`; value object does not
CGAL-5 no `using namespace ...` at file scope (header leakage)
CGAL-6 no #define beyond CGAL_* / include-guard
Result on the current tree: 6 CGAL public headers, 0 violations.
The checker therefore doubles as documentation of the conventions
we already follow.
Both are wired into scripts/quality/run-all.sh's fast subset (~5 s
combined wall time). README.md updated to split the gates into a
"style/convention" group (cheap, run-on-every-commit material) and a
"correctness/quality" group (slow, run-before-tag material).
The reviewer-facing locked-vs-flexible.md gains another "✅ Closed"
row documenting both gates and the 0-violation baseline.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
76
.clang-format
Normal file
76
.clang-format
Normal file
@@ -0,0 +1,76 @@
|
||||
# conformallab++ formatting policy
|
||||
#
|
||||
# Captures the style already present in code/include/. Documented here
|
||||
# so clang-format can enforce it locally (scripts/quality/clang-format.sh)
|
||||
# and so new contributors get the same output their editor would on save.
|
||||
#
|
||||
# This is NOT the upstream CGAL clang-format (there isn't one published);
|
||||
# it's the style our tree already uses, mechanically extracted.
|
||||
|
||||
BasedOnStyle: LLVM
|
||||
Language: Cpp
|
||||
Standard: c++17
|
||||
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
ColumnLimit: 100 # loose; readability over hard wrap
|
||||
|
||||
# Brace placement — matches the project tree:
|
||||
# functions / methods → opening brace on a new line (CGAL convention)
|
||||
# structs / classes → opening brace on a new line
|
||||
# else / catch → on the same line as the closing brace of the preceding block
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterStruct: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterUnion: true
|
||||
AfterControlStatement: false
|
||||
BeforeElse: false
|
||||
BeforeCatch: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: true
|
||||
|
||||
# Reference & pointer modifiers attach to the type (`int& x`, not `int &x`).
|
||||
PointerAlignment: Left
|
||||
ReferenceAlignment: Left
|
||||
|
||||
# Aligned `using = ...` blocks are intentional in the trait classes.
|
||||
AlignConsecutiveDeclarations: AcrossEmptyLines
|
||||
AlignConsecutiveAssignments: AcrossEmptyLines
|
||||
AlignTrailingComments: true
|
||||
AlignAfterOpenBracket: Align
|
||||
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
|
||||
# Template-related: break before each parameter when the template line
|
||||
# would otherwise exceed ColumnLimit (matches existing
|
||||
# `template <typename TriangleMesh, typename ...>` patterns).
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BinPackParameters: false
|
||||
BinPackArguments: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
SpaceAfterTemplateKeyword: true
|
||||
|
||||
NamespaceIndentation: None
|
||||
AccessModifierOffset: -4
|
||||
IndentCaseLabels: false
|
||||
|
||||
# Includes: keep manual ordering — re-ordering can break Eigen / CGAL
|
||||
# transitive-include assumptions in subtle ways. We just enforce no
|
||||
# accidental duplicate blank lines.
|
||||
SortIncludes: Never
|
||||
MaxEmptyLinesToKeep: 1
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
|
||||
# Comments: don't touch.
|
||||
ReflowComments: false
|
||||
Reference in New Issue
Block a user