Skip to content

Commit c7bf245

Browse files
authored
style(core) - Minor style fixes. (#8)
## Description Minor style fixes. ## Type of Change - [ ] `feat` - New feature - [ ] `fix` - Bug fix - [ ] `docs` - Documentation update - [x] `style` - Code style changes (formatting) - [ ] `refactor` - Code refactoring - [ ] `perf` - Performance improvement - [ ] `test` - Test additions/fixes - [ ] `build` - Build system changes - [ ] `ci` - CI configuration changes ## Testing - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing performed - [x] All tests pass locally ## Code Quality - [x] Code follows the C++ Manual - [x] No compiler warnings - [x] Breaking changes documented (if any) - [x] Documentation updated ## AI Policy Compliance - [x] No AI-generated content - [ ] Contains AI-generated code (disclosed and reviewed) ## Checklist - [x] Branch is up-to-date with `main` - [x] Commit messages follow conventional format - [x] CI checks pass - [x] Self-review completed
2 parents 2311b16 + 31b8029 commit c7bf245

File tree

16 files changed

+94
-94
lines changed

16 files changed

+94
-94
lines changed

docs/contributing/ai-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ auto result = some_complex_ai_generated_function_i_dont_understand();
154154
// ✅ Good: Understand and improve AI suggestions
155155
// AI suggested basic version, but I added error handling and
156156
// adapted to our std::error_code/std::expected pattern
157-
[[OAT_NODISCARD("Please remember to verify the std::expected result.")]]
157+
[[ION_NODISCARD("Please remember to verify the std::expected result.")]]
158158
std::expected<processed_data, std::error_code> process_data(buffer_view input) {
159159
if (input.empty()) {
160160
return std::unexpected(std::make_error_code(std::errc::bad_message));

docs/contributing/code-review.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ for (auto it = vec.begin(); it != vec.end(); it++) {
165165
- [ ] No naked `new`/`delete` - use `std::unique_ptr`
166166
- [ ] Factory functions return `std::expected<std::unique_ptr<T>, std::error_code>`
167167
- [ ] No exceptions escaping module boundaries
168-
- [ ] Proper `[[OAT_NODISCARD("...")]]
168+
- [ ] Proper `[[ION_NODISCARD("...")]]
169169
` usage
170170
- [ ] Interface segregation (pure virtual interfaces)
171171
- [ ] No `std::shared_ptr` without justification

docs/development/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class renderer_impl : public renderer_base {
157157
```
158158
159159
### 4. **Explicit Error Handling**
160-
Every fallible operation returns `std::expected<T, std::error_code>` and is marked `[[OAT_NODISCARD("...")]]`.
160+
Every fallible operation returns `std::expected<T, std::error_code>` and is marked `[[ION_NODISCARD("...")]]`.
161161
162162
## Common Tasks
163163

docs/development/cpp-manual.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ All runtime code SHALL use `std::expected` for error propagation. See API.3 for
149149
```cpp
150150
// Example of catching an internal exception in a factory
151151
// static
152-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
152+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
153153
std::expected<std::unique_ptr<my_object>, std::error_code> my_object::create(const std::string& config_data) {
154154
try {
155155
// my_object_impl constructor might throw on bad config_data
@@ -186,7 +186,7 @@ public:
186186
virtual ~my_object() = default;
187187
188188
// Factory function
189-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
189+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
190190
static std::expected<std::unique_ptr<my_object>, std::error_code> create(...);
191191
192192
protected:
@@ -250,7 +250,7 @@ These layers establish strict boundaries crucial for maintainability, testabilit
250250
251251
1. **`[ Interface Layer ]`**
252252
* **Location:** `include/oat/yourlib/...` (or similar public include path)
253-
* **Content:** Public headers defining abstract classes (interfaces), POD-like configuration structs, public enums (like `ErrorCode`), and factory function declarations (e.g., `static std::expected<std::unique_ptr<type_base>, std::error_code> create(...)`).
253+
* **Content:** Public headers defining abstract classes (interfaces), POD-like configuration structs, public enums (like `log_level`), and factory function declarations (e.g., `static std::expected<std::unique_ptr<type_base>, std::error_code> create(...)`).
254254
* **Rule:** Interfaces expose **nothing private**. No implementation details, no private helper classes, no internal data structures. They define the "what," not the "how."
255255
256256
2. **`[ Implementation Layer ]`**
@@ -282,7 +282,7 @@ These layers establish strict boundaries crucial for maintainability, testabilit
282282
283283
virtual void tick(uint64_t now_ns) = 0;
284284
285-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
285+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
286286
virtual std::expected<void, std::error_code> send_message(buffer_view payload) = 0;
287287
// ... other interface methods
288288
};
@@ -437,7 +437,7 @@ This convention enhances readability and consistency.
437437
| Private Implementation Source | `snake_case_impl.cpp`| `session_manager_impl.cpp` | `src/session_manager_impl.cpp` |
438438
| Utility/Helper Header (Public) | `snake_case.h` | `buffer_utils.h` | `include/oat/core/buffer_utils.h` |
439439
| Utility/Helper Source (Private) | `snake_case.cpp` | `string_helpers.cpp` | `src/string_helpers.cpp` |
440-
| Test Source File | `PascalCaseTests.cpp` or `feature_tests.cpp` | `session_manager_tests.cpp` | `tests/session_manager_tests.cpp` |
440+
| Test Source File | `snake_cast_test.cpp` or `feature_tests.cpp` | `session_manager_tests.cpp` | `tests/session_manager_tests.cpp` |
441441
| Class / Struct / Enum Class | `PascalCase` | `session_manager` | (Defined inside headers/sources) |
442442
| Enum (C-style, if unavoidable) | `ALL_CAPS_SNAKE` | `MAX_CONNECTIONS` | (Strongly prefer `enum class`) |
443443
@@ -556,16 +556,16 @@ private:
556556
```cpp
557557
class data_processor {
558558
public:
559-
[[OAT_NODISCARD("handle this result – failure to do so is a bug.")]]
560-
static std::expected<std::unique_ptr<data_processor>, error>
559+
[[ION_NODISCARD("handle this result – failure to do so is a bug.")]]
560+
static std::expected<std::unique_ptr<data_processor>, std::error_code>
561561
create(config& cfg); // factory, still snake_case
562562

563563
void submit_data(buffer_view data);
564564

565-
[[OAT_NODISCARD("handle this result – failure to do so is a bug.")]]
565+
[[ION_NODISCARD("handle this result – failure to do so is a bug.")]]
566566
bool is_processing() const;
567567

568-
[[OAT_NODISCARD("handle this result – failure to do so is a bug.")]]
568+
[[ION_NODISCARD("handle this result – failure to do so is a bug.")]]
569569
std::optional<result> get_result();
570570

571571
private:
@@ -658,7 +658,7 @@ Strive to minimize the `#include` directives in your header files.
658658
// my_service.h
659659
#pragma once
660660
#include <memory> // For std::unique_ptr
661-
#include <oat/core/error_code.h> // For ErrorCode, error (Tagged Enum Wrapper)
661+
#include <oat/core/error.h> // for core_errc
662662
#include <oat/core/buffer_view.h> // For buffer_view
663663

664664
// Forward declarations
@@ -768,7 +768,7 @@ public:
768768

769769
class logger_factory {
770770
public:
771-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
771+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
772772
virtual std::expected<std::unique_ptr<logger_base>, std::error_code> create_logger() = 0;
773773
virtual ~logger_factory() = default;
774774
};
@@ -791,7 +791,7 @@ public:
791791
stream_ << msg << '\n';
792792
}
793793
794-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
794+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
795795
static std::expected<std::unique_ptr<logger_base>, std::error_code> create(std::string_view path) {
796796
try {
797797
auto logger = std::unique_ptr<concrete_logger>(new concrete_logger(path));
@@ -831,7 +831,7 @@ private:
831831

832832
class concrete_logger_factory : public logger_factory_base {
833833
public:
834-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
834+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
835835
std::expected<std::unique_ptr<logger_base>, std::error_code> create_logger() override {
836836
return concrete_logger::create("log.txt");
837837
}
@@ -881,7 +881,7 @@ void reset_logger_factory() {
881881
class mock_logger : public logger_base { /* ... */ };
882882
class mock_logger_factory : public logger_factory_base {
883883
public:
884-
[[OAT_NODISCARD("Handle this result! Failure to do so is a bug.")]]
884+
[[ION_NODISCARD("Handle this result! Failure to do so is a bug.")]]
885885
std::expected<std::unique_ptr<logger_base>, std::error_code> create_logger() override {
886886
return std::make_unique<mock_logger>();
887887
}
@@ -999,7 +999,7 @@ All public functions that can fail **shall**
999999
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
10001000
| **Return** `std::expected<T, std::error_code>` (or `std::expected<void, std::error_code>`). | The value half (`T`) remains unconstrained; the error half is the *portable* C++11 struct whose layout is ABI-stable across DLLs. |
10011001
| **Tag** every error code with a *module-local* strongly-typed `enum class`, then convert it to `std::error_code` via `make_error_code`. | Preserves type-safety at call sites while keeping one on-the-wire format. |
1002-
| **Mark** every fallible API with `OAT_NODISCARD("…descriptive message…")`. | Forces callers to handle the result. |
1002+
| **Mark** every fallible API with `ION_NODISCARD("…descriptive message…")`. | Forces callers to handle the result. |
10031003
10041004
`bool`, sentinels, `nullptr`, raw integers, or `std::optional` **shall not** be used for error signalling. Exceptions remain an internal implementation detail; they do **not** cross public ABI boundaries.
10051005
@@ -1100,7 +1100,7 @@ static std::error_code to_net_error(std::error_code ec) noexcept {
11001100
*Exported API*:
11011101

11021102
```cpp
1103-
[[OAT_NODISCARD("check connect result")]]
1103+
[[ION_NODISCARD("check connect result")]]
11041104
std::expected<void, std::error_code> connect(socket s, address a)
11051105
{
11061106
if (::connect(s.fd(), …) == 0) return {};
@@ -1118,21 +1118,21 @@ No caller ever sees `errno` or `DWORD`, only `oat::net::net_errc`.
11181118
// oat/attributes.h
11191119
#pragma once
11201120
#if defined(__GNUC__) || defined(__clang__)
1121-
# define OAT_NODISCARD(msg) nodiscard(msg), gnu::warn_unused_result
1121+
# define ION_NODISCARD(msg) nodiscard(msg), gnu::warn_unused_result
11221122
#elif defined(_MSC_VER)
1123-
# define OAT_NODISCARD(msg) nodiscard(msg)
1123+
# define ION_NODISCARD(msg) nodiscard(msg)
11241124
#else
1125-
# define OAT_NODISCARD(msg) nodiscard
1125+
# define ION_NODISCARD(msg) nodiscard
11261126
#endif
11271127
```
11281128

11291129
*Usage examples*:
11301130

11311131
```cpp
1132-
OAT_NODISCARD("handle the possible timeout")
1132+
ION_NODISCARD("handle the possible timeout")
11331133
std::expected<void, std::error_code> wait_for_ready(...);
11341134

1135-
OAT_NODISCARD("did the asset actually load?")
1135+
ION_NODISCARD("did the asset actually load?")
11361136
std::expected<asset, std::error_code> load_asset(std::string_view path);
11371137
```
11381138
@@ -1168,7 +1168,7 @@ Each message explains *why* the caller shouldn’t ignore the value.
11681168
* **Interoperable:** STL, Boost, gRPC and many third-party libraries already consume/produce `std::error_code`.
11691169
* **Extensible:** each module owns its enum; no global registry or range reservation is required.
11701170
* **Descriptive:** `message()` delivers human-readable text on demand; not stored unless logged.
1171-
* **Enforced handling:** `OAT_NODISCARD` ensures the compiler reminds users to check every result.
1171+
* **Enforced handling:** `ION_NODISCARD` ensures the compiler reminds users to check every result.
11721172
11731173
Adhering to these rules yields clear, efficient, and portable error handling across all OAT C++ components.
11741174

docs/development/creating-apps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public:
145145
};
146146

147147
// Factory
148-
[[OAT_NODISCARD("Please make sure to handle the creation failure.")]]
148+
[[ION_NODISCARD("Please make sure to handle the creation failure.")]]
149149
static std::expected<std::unique_ptr<application>, std::error_code>
150150
create(const config& config);
151151

@@ -158,7 +158,7 @@ public:
158158
private:
159159
application(const config& config);
160160

161-
[[OAT_NODISCARD("Please ensure to handle init failure.")]]
161+
[[ION_NODISCARD("Please ensure to handle init failure.")]]
162162
std::expected<void, std::error_code> initialize();
163163

164164
void update(float delta_time);

docs/development/creating-libraries.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace ion::your_library {
6767
class your_type_base;
6868

6969
// Factory function declaration
70-
[[OAT_NODISCARD("Please ensure that the result is valid.")]]
70+
[[ION_NODISCARD("Please ensure that the result is valid.")]]
7171
std::expected<std::unique_ptr<your_type_base>, std::error_code>
7272
make_your_type(/* parameters */);
7373

@@ -79,7 +79,7 @@ public:
7979
// Core functionality
8080
virtual void do_something() = 0;
8181

82-
[[OAT_NODISCARD("Please don't forget to check the result.")]]
82+
[[ION_NODISCARD("Please don't forget to check the result.")]]
8383
virtual std::expected<int, std::error_code> compute_value() = 0;
8484

8585
// No implementation details in interface!
@@ -106,7 +106,7 @@ namespace ion::your_library::detail {
106106
class your_type_impl final : public your_type_base {
107107
public:
108108
// Factory method
109-
[[OAT_NODISCARD("Handle the result")]]
109+
[[ION_NODISCARD("Handle the result")]]
110110
static std::expected<std::unique_ptr<your_type_impl>, std::error_code>
111111
create(/* parameters */);
112112
@@ -264,7 +264,7 @@ TEST_CASE("YourInterface basic operations", "[your_library]") {
264264
SECTION("Creation fails with invalid parameters") {
265265
auto result = make_your_interface(/* invalid params */);
266266
REQUIRE(!result.has_value());
267-
REQUIRE(result.error().code() == ErrorCode::invalid_parameter);
267+
REQUIRE(result.error() == core_errc::invalid_parameter);
268268
}
269269

270270
SECTION("Operations work correctly") {
@@ -357,7 +357,7 @@ Any important implementation details...
357357
- ✅ Keep interfaces minimal and focused
358358
- ✅ Hide all implementation details
359359
- ✅ Use `std::expected` for all fallible operations
360-
- ✅ Mark functions `[[OAT_NODISCARD("...")]]` when appropriate
360+
- ✅ Mark functions `[[ION_NODISCARD("...")]]` when appropriate
361361
- ✅ Follow the dependency hierarchy strictly
362362
- ✅ Write comprehensive tests
363363
- ✅ Document the public API

docs/development/testing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TEST_CASE("Feature description", "[your_library]") {
5454

5555
// Assert
5656
REQUIRE(!system.has_value());
57-
REQUIRE(system.error().code() == ErrorCode::InvalidConfig);
57+
REQUIRE(system.error() == core_errc::invalid_config);
5858
}
5959
}
6060
```
@@ -88,22 +88,22 @@ TEST_CASE("Async operations complete correctly", "[async]") {
8888
### Testing State Machines
8989

9090
```cpp
91-
TEST_CASE("State machine transitions", "[state]") {
92-
auto machine = makeStateMachine();
91+
TEST_CASE("state machine transitions", "[state]") {
92+
auto machine = make_state_machine();
9393
REQUIRE(machine.has_value());
9494

9595
// Initial state
96-
REQUIRE(machine.value()->getState() == State::Idle);
96+
REQUIRE(machine.value()->get_state() == state::idle);
9797

9898
// Valid transition
99-
auto result = machine.value()->transition(Event::Start);
99+
auto result = machine.value()->transition(event::start);
100100
REQUIRE(result.has_value());
101-
REQUIRE(machine.value()->getState() == State::Running);
101+
REQUIRE(machine.value()->get_state() == state::running);
102102

103103
// Invalid transition
104-
result = machine.value()->transition(Event::Start);
104+
result = machine.value()->transition(event::start);
105105
REQUIRE(!result.has_value());
106-
REQUIRE(result.error().code() == ErrorCode::InvalidTransition);
106+
REQUIRE(result.error().code() == core_errc::InvalidTransition);
107107
}
108108
```
109109

libs/core/include/ion/core/buffer/buffer_base.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ class ION_CORE_API buffer_base {
1111
public:
1212
virtual ~buffer_base() = default;
1313

14-
[[OAT_NODISCARD("Handle resize result")]]
14+
[[ION_NODISCARD("Handle resize result")]]
1515
virtual std::expected<void, std::error_code> resize(std::size_t bytes) = 0;
1616

17-
[[OAT_NODISCARD("Handle reserve result")]]
17+
[[ION_NODISCARD("Handle reserve result")]]
1818
virtual std::expected<void, std::error_code> reserve(std::size_t bytes) = 0;
1919

20-
[[OAT_NODISCARD("Handle clear result")]]
20+
[[ION_NODISCARD("Handle clear result")]]
2121
virtual std::expected<void, std::error_code> clear() = 0;
2222

23-
[[OAT_NODISCARD("Handle shrink result")]]
23+
[[ION_NODISCARD("Handle shrink result")]]
2424
virtual std::expected<void, std::error_code> shrink_to_fit() = 0;
2525

26-
[[OAT_NODISCARD("Handle append result")]]
26+
[[ION_NODISCARD("Handle append result")]]
2727
virtual std::expected<void, std::error_code> append(std::span<const std::byte> src) = 0;
2828

29-
[[OAT_NODISCARD("Handle view result")]]
29+
[[ION_NODISCARD("Handle view result")]]
3030
virtual std::span<const std::byte> view() const noexcept = 0;
3131

32-
[[OAT_NODISCARD("Handle mutate result")]]
32+
[[ION_NODISCARD("Handle mutate result")]]
3333
virtual std::span< std::byte> mutate() noexcept = 0;
3434

35-
[[OAT_NODISCARD("Handle size result")]]
35+
[[ION_NODISCARD("Handle size result")]]
3636
virtual std::size_t size() const noexcept = 0;
3737

38-
[[OAT_NODISCARD("Handle capacity result")]]
38+
[[ION_NODISCARD("Handle capacity result")]]
3939
virtual std::size_t capacity() const noexcept = 0;
4040
};
4141

libs/core/include/ion/core/buffer/buffer_factory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
namespace ion::core {
99

1010
// Factory function to create a dynamic buffer with an optional initial capacity
11-
[[OAT_NODISCARD("Handle buffer creation result")]]
11+
[[ION_NODISCARD("Handle buffer creation result")]]
1212
ION_CORE_API std::expected<std::unique_ptr<buffer_base>, std::error_code>
1313
create_buffer(std::size_t initial_capacity = 0);
1414

1515
// Factory function to create a static buffer with a fixed size
1616
template <std::size_t N>
17-
[[OAT_NODISCARD("Handle static buffer creation result")]]
17+
[[ION_NODISCARD("Handle static buffer creation result")]]
1818
std::expected<std::unique_ptr<buffer_base>, std::error_code>
1919
create_static_buffer() {
2020
return std::make_unique<detail::StaticBuffer<N>>();

libs/core/include/ion/core/logging/logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ION_CORE_API logger_base {
2828
std::vformat(fmt, std::make_format_args(std::forward<Args>(args)...)));
2929
}
3030

31-
[[OAT_NODISCARD("You should be actually checking this if you're bothering to call it.")]]
31+
[[ION_NODISCARD("You should be actually checking this if you're bothering to call it.")]]
3232
virtual bool is_enabled(log_level level) const = 0;
3333
};
3434

0 commit comments

Comments
 (0)