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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
Language: Cpp
BasedOnStyle: Google
Standard: c++11
ColumnLimit: 120
IndentWidth: 4
ContinuationIndentWidth: 4
TabWidth: 4
UseTab: Never
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Attach
DerivePointerAlignment: false
PointerAlignment: Left
SortIncludes: CaseSensitive
IncludeBlocks: Regroup
NamespaceIndentation: None
...
24 changes: 24 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
Checks: >
-*,
bugprone-*,
clang-analyzer-*,
performance-*,
portability-*,
readability-braces-around-statements,
readability-const-return-type,
readability-container-size-empty,
readability-duplicate-include,
readability-misleading-indentation,
readability-redundant-member-init,
readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-static-accessed-through-instance
WarningsAsErrors: ''
HeaderFilterRegex: '(^|.*/)(include|src|tests)/.*'
FormatStyle: file
CheckOptions:
- key: readability-braces-around-statements.ShortStatementLines
value: '1'
...
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

## Code style

This project uses LLVM tooling for formatting and lightweight linting:

- `clang-format` reads `.clang-format`.
- `clang-tidy` reads `.clang-tidy`.

The formatting style is based on Google C++ style with a 4-space indent and a
120-column limit. New and modified C++ code should follow the local naming
patterns already used by the public API:

- types and public API classes: `PascalCase`
- public member functions: `PascalCase`
- free functions used as internal helpers: `PascalCase` when matching existing
code, otherwise descriptive lower-case names are preferred for new private
helpers
- variables, data members, and parameters: `snake_case`
- private data members: trailing underscore, for example `db_`
- constants and enum values: existing project style, for example `kText`
- macros: `UPPER_SNAKE_CASE`

Do not reformat vendored third-party sources:

- `src/sqlite3.c`
- `src/internal/sqlite3.h`
- `src/internal/date.h`

## Formatting changed files

Run `clang-format` only on project-owned C++ files that you changed:

```console
clang-format -i include/database.h src/database.cc tests/database_test.cc
```

To inspect formatting without modifying files:

```console
clang-format --dry-run --Werror include/database.h src/database.cc tests/database_test.cc
```

## Linting

After configuring CMake with compile commands enabled, run `clang-tidy` on the
files you changed:

```console
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
clang-tidy src/database.cc -p build
```

Keep lint fixes focused on the code touched by the current change. Avoid broad
style-only rewrites unless the change is explicitly scoped as a formatting PR.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ A C++ wrapper for SQLite that provides compile-time checked CRUD operations for
- [Raw SQL](#raw-sql)
- [Build instructions](#build-instructions)
- [Dependencies](#dependencies)
- [Contributing](#contributing)

## Motivation

Expand Down Expand Up @@ -391,3 +392,8 @@ You can also open the generated `build/sqlite-cpp-reflection.sln` in Visual Stud
- A C++11-compatible compiler
- GoogleTest for tests, fetched by CMake
- SQLite, vendored in `src/sqlite3.c` and `src/internal/sqlite3.h`

## Contributing

Formatting and linting rules are documented in [CONTRIBUTING.md](CONTRIBUTING.md). The repository includes
`.clang-format` and `.clang-tidy` so contributors can format and lint changed C++ files consistently.
Loading
Loading