Skip to content

Commit 6643d42

Browse files
refactor(kv-ir): Resolve clang-tidy violations in clp/ffi/ir_stream/{Deserializer,IrUnitHandlerReq}.hpp. (#917)
1 parent c237d67 commit 6643d42

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

components/core/src/clp/ffi/ir_stream/Deserializer.hpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef CLP_FFI_IR_STREAM_DESERIALIZER_HPP
22
#define CLP_FFI_IR_STREAM_DESERIALIZER_HPP
33

4-
#include <concepts>
54
#include <cstdint>
65
#include <memory>
76
#include <string>
@@ -10,19 +9,25 @@
109
#include <vector>
1110

1211
#include <nlohmann/json.hpp>
12+
#include <nlohmann/json_fwd.hpp>
1313
#include <outcome/outcome.hpp>
1414

1515
#include "../../ReaderInterface.hpp"
1616
#include "../../time_types.hpp"
1717
#include "../SchemaTree.hpp"
18-
#include "decoding_methods.hpp"
1918
#include "ir_unit_deserialization_methods.hpp"
2019
#include "IrUnitHandlerReq.hpp"
2120
#include "IrUnitType.hpp"
2221
#include "protocol_constants.hpp"
22+
#include "search/AstEvaluationResult.hpp"
2323
#include "search/QueryHandlerReq.hpp"
2424
#include "utils.hpp"
2525

26+
// This include has a circular dependency with the `.inc` file.
27+
// The following clang-tidy suppression should be removed once the circular dependency is resolved.
28+
// NOLINTNEXTLINE(misc-header-include-cycle)
29+
#include "decoding_methods.hpp"
30+
2631
namespace clp::ffi::ir_stream {
2732
/**
2833
* A deserializer for reading IR units from a CLP kv-pair IR stream. An IR unit handler should be
@@ -291,26 +296,23 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
291296
auto const ir_unit_type{optional_ir_unit_type.value()};
292297
switch (ir_unit_type) {
293298
case IrUnitType::LogEvent: {
294-
auto result{deserialize_ir_unit_kv_pair_log_event(
299+
auto log_event{OUTCOME_TRYX(deserialize_ir_unit_kv_pair_log_event(
295300
reader,
296301
tag,
297302
m_auto_gen_keys_schema_tree,
298303
m_user_gen_keys_schema_tree,
299304
m_utc_offset
300-
)};
301-
if (result.has_error()) {
302-
return result.error();
303-
}
305+
))};
304306

305307
if constexpr (search::IsNonEmptyQueryHandler<QueryHandlerType>::value) {
306308
if (search::AstEvaluationResult::True
307-
!= OUTCOME_TRYX(m_query_handler.evaluate_kv_pair_log_event(result.value())))
309+
!= OUTCOME_TRYX(m_query_handler.evaluate_kv_pair_log_event(log_event)))
308310
{
309311
break;
310312
}
311313
}
312314

313-
if (auto const err{m_ir_unit_handler.handle_log_event(std::move(result.value()))};
315+
if (auto const err{m_ir_unit_handler.handle_log_event(std::move(log_event))};
314316
IRErrorCode::IRErrorCode_Success != err)
315317
{
316318
return ir_error_code_to_errc(err);
@@ -320,14 +322,9 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
320322

321323
case IrUnitType::SchemaTreeNodeInsertion: {
322324
std::string key_name;
323-
auto const result{
325+
auto const [is_auto_generated, node_locator]{OUTCOME_TRYX(
324326
deserialize_ir_unit_schema_tree_node_insertion(reader, tag, key_name)
325-
};
326-
if (result.has_error()) {
327-
return result.error();
328-
}
329-
330-
auto const& [is_auto_generated, node_locator]{result.value()};
327+
)};
331328
auto& schema_tree_to_insert{
332329
is_auto_generated ? m_auto_gen_keys_schema_tree : m_user_gen_keys_schema_tree
333330
};
@@ -359,12 +356,7 @@ auto Deserializer<IrUnitHandler, QueryHandlerType>::deserialize_next_ir_unit(
359356
}
360357

361358
case IrUnitType::UtcOffsetChange: {
362-
auto const result{deserialize_ir_unit_utc_offset_change(reader)};
363-
if (result.has_error()) {
364-
return result.error();
365-
}
366-
367-
auto const new_utc_offset{result.value()};
359+
auto const new_utc_offset{OUTCOME_TRYX(deserialize_ir_unit_utc_offset_change(reader))};
368360
if (auto const err{
369361
m_ir_unit_handler.handle_utc_offset_change(m_utc_offset, new_utc_offset)
370362
};

components/core/src/clp/ffi/ir_stream/IrUnitHandlerReq.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include "../../time_types.hpp"
99
#include "../KeyValuePairLogEvent.hpp"
1010
#include "../SchemaTree.hpp"
11+
12+
// This include has a circular dependency with the `.inc` file.
13+
// The following clang-tidy suppression should be removed once the circular dependency is resolved.
14+
// NOLINTNEXTLINE(misc-header-include-cycle)
1115
#include "decoding_methods.hpp"
1216

1317
namespace clp::ffi::ir_stream {

taskfiles/lint.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,9 @@ tasks:
252252
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/decoding_methods.cpp"
253253
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/decoding_methods.hpp"
254254
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/decoding_methods.inc"
255-
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/Deserializer.hpp"
256255
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/encoding_methods.cpp"
257256
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/encoding_methods.hpp"
258257
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/ir_unit_deserialization_methods.hpp"
259-
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/IrUnitHandlerInterface.hpp"
260258
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/protocol_constants.hpp"
261259
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/Serializer.cpp"
262260
- "{{.G_CORE_COMPONENT_DIR}}/src/clp/ffi/ir_stream/Serializer.hpp"

0 commit comments

Comments
 (0)