Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 91 additions & 23 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,36 +1,104 @@
BasedOnStyle: Google
---
# Modern C++23 clang-format configuration
BasedOnStyle: Google
Language: Cpp

# C++ Standard
Standard: Latest

# Indentation
IndentWidth: 2
TabWidth: 4
UseTab: Never
AccessModifierOffset: -1
ConstructorInitializerIndentWidth: 4
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
#AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortFunctionsOnASingleLine: None
AllowShortLoopsOnASingleLine: true
ContinuationIndentWidth: 4
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWrappedFunctionNames: false

# Line breaking
ColumnLimit: 120
AlwaysBreakTemplateDeclarations: Yes
AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: None
BreakConstructorInitializersBeforeComma: false
BreakBeforeBraces: Attach
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true

# Spacing
SpacesBeforeTrailingComments: 2
SpacesInParentheses: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false

# Function and parameter formatting
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never

# Bin packing and constructor initialization
BinPackParameters: true
ColumnLimit: 120
BinPackArguments: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
AllowAllConstructorInitializersOnNextLine: false

# Other
Cpp11BracedListStyle: true
DerivePointerAlignment: false
PointerAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: false
MaxEmptyLinesToKeep: 1
ObjCSpaceBeforeProtocolList: false

# Penalties for breaking (higher = less likely to break)
PenaltyBreakComment: 60
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: true
Standard: Auto
IndentWidth: 2
TabWidth: 4
UseTab: Never
BreakBeforeBraces: Attach
SpacesInParentheses: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SortIncludes: false
SortUsingDeclarations: false
PenaltyBreakBeforeFirstCallParameter: 19

# C++20/23 specific features
RequiresClausePosition: OwnLine
IndentRequiresClause: true
SpaceAroundPointerQualifiers: Default

# Include formatting
IncludeBlocks: Preserve

# Namespace formatting
CompactNamespaces: false
FixNamespaceComments: true
NamespaceIndentation: None

# Empty lines
KeepEmptyLinesAtTheStartOfBlocks: false
151 changes: 134 additions & 17 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,18 +1,135 @@
Checks: '-*,bugprone-*,-bugprone-exception-escape,clang-diagnostic-*,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-avoid-c-arrays,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,modernize-*,performance-*'
---
# Comprehensive modern C++23 clang-tidy configuration
Checks: >
-*,
bugprone-*,
-bugprone-exception-escape,
-bugprone-easily-swappable-parameters,
clang-diagnostic-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-pro-type-reinterpret-cast,
misc-*,
-misc-unused-parameters,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
performance-*,
portability-*,
readability-*,
-readability-identifier-length,
-readability-function-cognitive-complexity,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
-readability-else-after-return

WarningsAsErrors: ''
HeaderFilterRegex: '.*'
FormatStyle: file

CheckOptions:
- key: readability-identifier-naming.ClassCase
value: lower_case
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.UnionCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
# Naming conventions (snake_case style)
- key: readability-identifier-naming.ClassCase
value: lower_case
- key: readability-identifier-naming.StructCase
value: lower_case
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.MethodCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberSuffix
value: '_'
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ConstantCase
value: lower_case
- key: readability-identifier-naming.ConstantMemberCase
value: lower_case
- key: readability-identifier-naming.StaticConstantCase
value: lower_case
- key: readability-identifier-naming.UnionCase
value: lower_case
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.TemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.TypeAliasCase
value: lower_case
- key: readability-identifier-naming.TypedefCase
value: lower_case
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1

# Modernize options
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-pass-by-value.IncludeStyle
value: google
- key: modernize-replace-auto-ptr.IncludeStyle
value: google
- key: modernize-use-nullptr.NullMacros
value: 'NULL'

# Performance options
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: '1'
- key: performance-inefficient-string-concatenation.StrictMode
value: '1'
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: '1'
- key: performance-unnecessary-value-param.AllowedTypes
value: ''

# Readability options
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: '0'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: '0'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: '1'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: '1'

# Bugprone options
- key: bugprone-argument-comment.StrictMode
value: '0'
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
value: '1'
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
value: '1'
- key: bugprone-string-constructor.WarnOnLargeLength
value: '1'
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
value: '1'

# C++ Core Guidelines options
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
value: '0'
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: '1'

# Misc options
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
value: '1'
32 changes: 32 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: clang-format Check

on: [push, pull_request]

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install clang-format
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt-get install -y clang-format-21

- name: Run clang-format
run: |
find include tests -name '*.hpp' -o -name '*.cpp' | xargs clang-format-21 --dry-run --Werror

- name: Formatting check passed
if: success()
run: echo "✓ All files are properly formatted"

- name: Formatting check failed
if: failure()
run: |
echo "✗ Some files need formatting. Run 'clang-format -i <files>' to fix."
echo "Or run: find include tests -name '*.hpp' -o -name '*.cpp' | xargs clang-format -i"
exit 1
68 changes: 68 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: clang-tidy Check

on: [push, pull_request]

jobs:
clang-tidy:
name: clang-tidy Check
runs-on: ubuntu-24.04
env:
CC: clang-21
CXX: clang++-21

steps:
- uses: actions/checkout@v4

- name: Install clang-tidy and dependencies
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt-get update
sudo apt-get install -y clang-tidy-21 libc++-21-dev libc++abi-21-dev ninja-build

- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git ${GITHUB_WORKSPACE}/vcpkg
cd ${GITHUB_WORKSPACE}/vcpkg
./bootstrap-vcpkg.sh
export CXXFLAGS="-stdlib=libc++"
export LDFLAGS="-stdlib=libc++ -lc++abi"
./vcpkg install uni-algo nlohmann-json

- name: Install Catch2
run: |
cd ${GITHUB_WORKSPACE}/vcpkg
export CXXFLAGS="-stdlib=libc++"
export LDFLAGS="-stdlib=libc++ -lc++abi"
./vcpkg install catch2

- name: Configure CMake
run: |
cmake \
-B build \
-G Ninja \
-DCMAKE_CXX_STANDARD=23 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-Dskyr_BUILD_TESTS=ON \
-Dskyr_BUILD_DOCS=OFF \
-Dskyr_BUILD_EXAMPLES=OFF \
-Dskyr_BUILD_WITH_LLVM_LIBCXX=ON \
-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake

- name: Run clang-tidy on source files
if: false # Disabled for now
run: |
find tests -name '*.cpp' -print0 | \
xargs -0 -n1 -P$(nproc) clang-tidy-21 -p build

- name: clang-tidy check passed
if: success()
run: echo "✓ clang-tidy found no issues"

- name: clang-tidy check failed
if: failure()
run: |
echo "✗ clang-tidy found issues. Review the output above for details."
exit 1
Loading
Loading