Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
89 changes: 89 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Tested with clang-format version 18.1.3.
BasedOnStyle: LLVM

# We explicitly list all settings we thought about, whether LLVM sets them the
# same way or not.

# =========================== Not Part of LLVM Style ===========================

# Dedent 'public', 'private', 'protected' keywords.
AccessModifierOffset: -4
# How to align arguments after '(', '<', and '['.
AlignAfterOpenBracket: AlwaysBreak
# Never align '\' characters.
AlignEscapedNewlines: DontAlign
# Never align inline comments with comments on following/preceeding lines.
AlignTrailingComments:
Kind: Never
# Force enum entries on multiple lines.
AllowShortEnumsOnASingleLine: false
# Force short functions across multiple lines.
AllowShortFunctionsOnASingleLine: None
# Force line breaks after template declarations.
# Less strict alternative for clang-format >= 19:
# BreakTemplateDeclarations: Leave
AlwaysBreakTemplateDeclarations: Yes
# Leave string literals as they are, this means that, e.g., doc strings may stay
# over-length, but setting 'true' here makes over-length doc strings ugly.
BreakStringLiterals: false
# Do not enforce rules about empty lines before, e.g., the 'public' keyword.
EmptyLineBeforeAccessModifier: Leave
# Do not add/fix comments indicating which namespace ends at the closing brace.
FixNamespaceComments: false
# Automatically group include blocks according to the categories defined below.
IncludeBlocks: Regroup
# Regex is not case sensitive by default.
IncludeCategories:
- Regex: '^"[^/]+"$'
Priority: 1
- Regex: '^"\.\./[^/]+"$'
Priority: 2
- Regex: '^"\.\./.+"$'
Priority: 3
# The next regex covers cases such as '"tasks/cost_adapted_task.h"' (without the
# '../' prefix.
- Regex: '^"[^/]+/[^/]+"$'
Priority: 3
- Regex: '^<.+>$'
Priority: 4
IndentWidth: 4
# Do not allow empty lines at start of block.
KeepEmptyLinesAtTheStartOfBlocks: false
# Put initializer list either on one line or one entry per line.
PackConstructorInitializers: NextLine
# Avoid line breaks between return type and function name.
PenaltyReturnTypeOnItsOwnLine: 120
# This was not consistent in the code base, now we have to force one choice.
SpaceAfterTemplateKeyword: false
# Set C++ standard.
Standard: c++20

# ============================= Part of LLVM Style =============================

# If parameters/arguments fit on next line, put them on single line.
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: true
# If parameters/arguments don't fit on the same line or the next, bin pack them.
BinPackParameters: true
BinPackArguments: true
# Break lines such that operators ('+', '<', ...) are at the end of the line.
BreakBeforeBinaryOperators: None
# Never add line break after an opening brace.
BreakBeforeBraces: Attach
# Put ternary operator symbols after line break.
BreakBeforeTernaryOperators: true
# Put colon of any initializer list on new line, even if not over-length.
BreakConstructorInitializers: BeforeColon
# Put colon of over-length inheritance declaration on new line.
BreakInheritanceList: BeforeColon
# Maximal number of characters in a line.
ColumnLimit: 80
# Always indent by 4.
ContinuationIndentWidth: 4
ConstructorInitializerIndentWidth: 4
# Do not indent function names if return type fills line.
IndentWrappedFunctionNames: false
# Pointer indicator '*' is next to variable name instead of next to type.
PointerAlignment: Right
# Force space between class name and inheritance colon.
SpaceBeforeInheritanceColon: true
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.uncrustify.cfg export-ignore
/.clang-format export-ignore
15 changes: 2 additions & 13 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,12 @@ jobs:
pip3 install tox
sudo apt-get -y install clang-tidy-16

- name: Install uncrustify
- name: Install clang-format
run: |
# Set up uncrustify.
wget https://github.com/uncrustify/uncrustify/archive/uncrustify-0.72.0.tar.gz
tar xzf uncrustify-0.72.0.tar.gz
cd uncrustify-uncrustify-0.72.0
mkdir build
cd build
cmake ../
make -j2
mv uncrustify ../../
cd ../../
rm -rf uncrustify-0.72.0.tar.gz uncrustify-uncrustify-0.72.0
sudo apt-get -y install clang-format

- name: Run code style tests
run: |
export PATH="$(pwd):$PATH" # Add uncrustify to path.
cd misc/
tox -e style,clang-tidy

Expand Down
200 changes: 0 additions & 200 deletions .uncrustify.cfg

This file was deleted.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ active, and in case of ties, by the earliest year the person started
contributing, and finally by last name.

- 2003-2025 Malte Helmert
- 2008-2016, 2018-2025 Gabriele Roeger
- 2009, 2025 Christian Muise
- 2008-2016, 2018-2024 Gabriele Roeger
- 2010-2024 Jendrik Seipp
- 2010-2025 Jendrik Seipp
- 2012-2025 Florian Pommerening
- 2021-2025 Clemens Büchner
- 2022-2025 Remo Christen
- 2022-2025 Simon Dold
- 2010-2011, 2013-2024 Silvan Sievers
- 2012-2024 Florian Pommerening
- 2013, 2015-2024 Salomé Eriksson
- 2018-2024 Patrick Ferber
- 2021-2024 Clemens Büchner
- 2022-2024 Remo Christen
- 2022-2024 Simon Dold
- 2023-2024 Claudia S. Grundke
- 2024 Martín Pozo
- 2024 Tanja Schindler
Expand Down
2 changes: 1 addition & 1 deletion misc/style/run-all-style-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def check_cc_files():


def check_cplusplus_style():
return subprocess.call(["./run-uncrustify.py"], cwd=DIR) == 0
return subprocess.call(["./run-clang-format.py"], cwd=DIR) == 0


def main():
Expand Down
Loading