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
82 changes: 82 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
Language: Cpp
Standard: c++17
BasedOnStyle: LLVM

# Line length
ColumnLimit: 120

# Indentation
IndentWidth: 4
UseTab: Never
IndentCaseLabels: true
IndentPPDirectives: AfterHash

# Spacing
SpaceBeforeParens: ControlStatements
SpaceAfterCStyleCast: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpaceBeforeAssignmentOperators: true

# Pointers and references
PointerAlignment: Left

# Braces
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

# Function definitions
AllowShortFunctionsOnASingleLine: None
SeparateDefinitionBlocks: Always
AllowShortBlocksOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true

# Constructor/Destructor
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
Cpp11BracedListStyle: true

# Operators
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true

# Includes
SortIncludes: true
IncludeBlocks: Preserve

# Comments
ReflowComments: true

# Other
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignTrailingComments: true

AccessModifierOffset: -2
CompactNamespaces: false
FixNamespaceComments: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
45 changes: 45 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# Clang-tidy configuration for Z80 emulator project
Checks: |
-*,
readability-*,
performance-*,
modernize-*,
bugprone-*,
clang-diagnostic-*,
cppcoreguidelines-*,
google-*,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-google-readability-function-size,
-google-runtime-references,
-modernize-use-trailing-return-type,
-cppcoreguidelines-pro-bounds-constant-array-index,
-readability-function-cognitive-complexity,
-readability-function-size

WarningsAsErrors: ''

# Configure individual checks
CheckOptions:
- key: 'readability-function-cognitive-complexity.Threshold'
value: '25'
- key: 'readability-function-size.StatementThreshold'
value: '800'
- key: 'readability-identifier-length.MinimumVariableNameLength'
value: '2'
- key: 'readability-identifier-length.MinimumParameterNameLength'
value: '2'
- key: 'readability-identifier-length.MinimumLoopCounterNameLength'
value: '1'
- key: 'readability-line-length.LineLength'
value: '120'
- key: 'bugprone-easily-swappable-parameters.MinimumLength'
value: '3'

HeaderFilterRegex: '.*'
InheritParentConfig: true
68 changes: 68 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Code Quality

on: [push, pull_request]

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

- name: Install clang-format
run: sudo apt-get install -y clang-format

- name: Check formatting
run: |
files=$(find include tests -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.tpp" \))
for file in $files; do
clang-format --dry-run -Werror "$file" || exit 1
done
echo "All files are properly formatted!"

static-analysis:
name: Static Analysis with clang-tidy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy cmake build-essential

- name: Build with compile_commands.json
run: |
mkdir -p build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
make

- name: Run clang-tidy
run: |
cd build
files=$(find ../tests -type f -name "*.cpp")
clang-tidy -p . $files

build:
name: Build Project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential

- name: Build
run: |
mkdir -p build
cd build
cmake ..
make -j4

- name: Run tests
run: |
cd build
ctest --output-on-failure
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Editor and OS files
.cache/
.idea/
.vscode/
.DS_Store

# Build directories
build*/

# Test ROMs
tests/roms/*
tests/roms/*.tap
Loading