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
78 changes: 67 additions & 11 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,77 @@
# Keep checks at tool defaults while treating all warnings as errors.
# clang-analyzer-* : enable static analysis passes for deeper bug finding
# clang-diagnostic-* : surface compiler-style warnings (unused variables, conversions, etc.)
# clang-diagnostic-unused-const-variable : warn on unused 'const' variables
# google-build-using-namespace : reject global using-namespace directives
# modernize-deprecated-headers : prefer C++ standard headers over legacy C ones
# modernize-loop-convert : prefer range-based for loops over traditional loops
# modernize-use-stdarray : prefer 'std::array' over C-style arrays
# modernize-use-using : prefer 'using' type alias declarations over 'typedef's
# readability-magic-numbers : discourage use of magic numbers in code
# misc-include-cleaner : ensure proper #includes are present and unused ones are removed
# modernize-* : enforce modern C++ idioms (e.g., avoid C arrays, prefer std::numbers)
# performance-* : flag common performance pitfalls
# readability-identifier-naming : enforce consistent identifier style
Checks: >
clang-analyzer-*,
clang-diagnostic-*,
clang-diagnostic-unused-const-variable,
google-build-using-namespace,
modernize-deprecated-headers,
modernize-loop-convert,
modernize-use-stdarray,
modernize-use-using
misc-include-cleaner,
modernize-*,
performance-*,
readability-identifier-naming

WarningsAsErrors: '*'

CheckOptions:
# ===== Types =====
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.TypeAliasCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase

# ===== Enum Values =====
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE

# ===== Functions & Methods =====
# (matches typical C++ engine style; avoids collision with OpenGL's mixed conventions)
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.MethodCase
value: lower_case

# ===== Variables =====
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case

# ===== Member Variables =====
# Strongly recommended for rendering code for clarity
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberPrefix
value: m_

# ===== Constants =====
- key: readability-identifier-naming.GlobalConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.StaticConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstexprVariableCase
value: UPPER_CASE

# ===== Modernize tuning =====
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-use-override.UseOverride
value: '1'
- key: modernize-avoid-c-arrays.CheckCStrings
value: '1'

# ===== Include cleaner =====
- key: misc-include-cleaner.StrictMode
value: '0'
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SHELL := /bin/bash
CC := gcc
TARGET := main
SRCS := main.cpp
# `-lstdc++` was added to resolve [this issue](https://stackoverflow.com/questions/33263288/libstdc-dso-missing-from-command-line)
# `-lm` was added to resolve [this issue](https://stackoverflow.com/questions/16006145/ld-undefined-reference-to-symbol-log2glibc-2-2-5)
LIBS := -lGL -lGLU -lglut -lIL -lILU -lILUT -lstdc++ -lm

all: $(TARGET)
Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ git clone https://github.com/robert-7/Go-Board-Game.git && cd Go-Board-Game
## Building and Running

Building requires the OpenGL and DevIL libraries imported.
To build the binary, simply run `make`.
To run the built binary, simply run `./main`.
To build and run the binary, simply run `make && ./main`.
To clean up, run `make clean`.

### Building Gotchas

* `-lstdc++` was added to resolve [this issue](https://stackoverflow.com/questions/33263288/libstdc-dso-missing-from-command-line)
* `-lm` was added to resolve [this issue](https://stackoverflow.com/questions/16006145/ld-undefined-reference-to-symbol-log2glibc-2-2-5).

## Linting

The repository uses the same commands locally and in CI. After installing the packages above, run:
Expand All @@ -50,7 +44,8 @@ The repository uses the same commands locally and in CI. After installing the pa
./scripts/run_lint.sh
```

The script configures CMake, runs clang-tidy, and then runs cppcheck with the same settings used in CI. It can be removed along with the `build` directory when you finish linting.
The script configures CMake, runs clang-tidy, and then runs cppcheck with the same settings used in CI.
It can be removed along with the `build` directory when you finish linting.

To run linting automatically before each commit, install [`pre-commit`](https://pre-commit.com/) (e.g., `pip install pre-commit` or `sudo apt install pre-commit`), then enable the hooks once:

Expand Down
Loading