diff --git a/.clang-tidy b/.clang-tidy index 154cb4e32..82b75971a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,18 @@ --- +Checks: > + boost-*, + bugprone-*, + clang-analyzer-*, + cppcoreguidelines-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -bugprone-unchecked-optional-access, + -cppcoreguidelines-avoid-magic-numbers, + -modernize-use-trailing-return-type, + -readability-identifier-length, + -readability-magic-numbers CheckOptions: - { key: readability-identifier-length.IgnoredParameterNames, value: 'i|j|k|c|os|it' } - { key: readability-identifier-length.IgnoredVariableNames, value: 'ec|id|it' } diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 62ccd9e34..f36af69a6 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -38,8 +38,8 @@ jobs: style: file # The file extensions to run the action against. This comma-separated string defaults to 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx'. # extensions: # optional, default is c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx - # A string of regex-like patterns specifying what checks clang-tidy will use. This defaults to 'boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*'. See also clang-tidy docs for more info. - tidy-checks: boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-*,cppcoreguidelines-* + # A blank string makes clang-tidy use only the checks in .clang-tidy files. + tidy-checks: '' # The relative path to the repository root directory. The default value '.' is relative to the runner's GITHUB_WORKSPACE environment variable. # repo-root: # optional, default is . # The desired version of the clang tools to use. Accepted options are strings which can be 15, 14, 13, 12, 11, 10, 9, or 8. Defaults to 12. diff --git a/libs/client-sdk/src/data_sources/fdv2/streaming_synchronizer.cpp b/libs/client-sdk/src/data_sources/fdv2/streaming_synchronizer.cpp index 2f52877b3..689440100 100644 --- a/libs/client-sdk/src/data_sources/fdv2/streaming_synchronizer.cpp +++ b/libs/client-sdk/src/data_sources/fdv2/streaming_synchronizer.cpp @@ -309,11 +309,14 @@ void FDv2StreamingSynchronizer::State::OnEvent(sse::Event const& event) { } else if constexpr (std::is_same_v) { if (r.kind == FDv2ProtocolHandler::Error::Kind::kServerError) { - auto const& id = r.server_error.value().id; + std::string id; + if (r.server_error) { + id = r.server_error->id.value_or(""); + } std::string msg = "An issue was encountered receiving updates for " "payload '" + - id.value_or("") + "' with reason: '" + r.message + + id + "' with reason: '" + r.message + "'. Automatic retry will occur."; LD_LOG(logger_, LogLevel::kInfo) << kIdentity << ": " << msg; diff --git a/libs/client-sdk/src/data_sources/polling_data_source.cpp b/libs/client-sdk/src/data_sources/polling_data_source.cpp index 4e50f612b..e6cd4bf21 100644 --- a/libs/client-sdk/src/data_sources/polling_data_source.cpp +++ b/libs/client-sdk/src/data_sources/polling_data_source.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include #include #include @@ -148,7 +148,14 @@ void PollingDataSource::HandlePollResult(network::HttpResult res) { << "Polling for feature flag updates failed: " << (res.ErrorMessage() ? *res.ErrorMessage() : "unknown error"); } else if (res.Status() == 200) { - data_source_handler_.HandleMessage("put", res.Body().value()); + if (res.Body()) { + data_source_handler_.HandleMessage("put", *res.Body()); + } else { + status_manager_.SetState( + DataSourceStatus::DataSourceState::kInterrupted, + DataSourceStatus::ErrorInfo::ErrorKind::kUnknown, + "Polling response contained no body"); + } } else if (res.Status() == 304) { // This should be handled ahead of here, but if we get a 304, // and it didn't have an etag, we still don't want to try to diff --git a/libs/server-sdk/src/data_systems/fdv2/fdv2_polling_impl.cpp b/libs/server-sdk/src/data_systems/fdv2/fdv2_polling_impl.cpp index 0b668851b..c57b82e6e 100644 --- a/libs/server-sdk/src/data_systems/fdv2/fdv2_polling_impl.cpp +++ b/libs/server-sdk/src/data_systems/fdv2/fdv2_polling_impl.cpp @@ -138,11 +138,14 @@ static FDv2SourceResult ParseFDv2PollEvents( } if (auto* error = std::get_if(&result)) { if (error->kind == FDv2ProtocolHandler::Error::Kind::kServerError) { - auto const& id = error->server_error.value().id; + std::string id; + if (error->server_error) { + id = error->server_error->id.value_or(""); + } std::string msg = "An issue was encountered receiving updates for " "payload '" + - id.value_or("") + "' with reason: '" + error->message + + id + "' with reason: '" + error->message + "'. Automatic retry will occur."; return FDv2SourceResult{FDv2SourceResult::Interrupted{ MakeError(ErrorKind::kErrorResponse, 0, std::move(msg))}}; diff --git a/libs/server-sdk/src/data_systems/fdv2/streaming_synchronizer.cpp b/libs/server-sdk/src/data_systems/fdv2/streaming_synchronizer.cpp index 0f09ef5cf..a8a6c4d00 100644 --- a/libs/server-sdk/src/data_systems/fdv2/streaming_synchronizer.cpp +++ b/libs/server-sdk/src/data_systems/fdv2/streaming_synchronizer.cpp @@ -272,11 +272,14 @@ void FDv2StreamingSynchronizer::State::OnEvent(sse::Event const& event) { } else if constexpr (std::is_same_v) { if (r.kind == FDv2ProtocolHandler::Error::Kind::kServerError) { - auto const& id = r.server_error.value().id; + std::string id; + if (r.server_error) { + id = r.server_error->id.value_or(""); + } std::string msg = "An issue was encountered receiving updates for " "payload '" + - id.value_or("") + "' with reason: '" + r.message + + id + "' with reason: '" + r.message + "'. Automatic retry will occur."; LD_LOG(logger_, LogLevel::kInfo) << kIdentity << ": " << msg; diff --git a/libs/server-sdk/src/evaluation/rules.cpp b/libs/server-sdk/src/evaluation/rules.cpp index 8e37259e9..5a5350242 100644 --- a/libs/server-sdk/src/evaluation/rules.cpp +++ b/libs/server-sdk/src/evaluation/rules.cpp @@ -4,6 +4,7 @@ #include "../data_components/big_segments/big_segment_store_wrapper.hpp" +#include #include #include #include @@ -30,8 +31,9 @@ enum EvaluationReason::BigSegmentsStatus ToBigSegmentsStatus( return EvaluationReason::BigSegmentsStatus::kHealthy; } -std::string MakeBigSegmentRef(Segment const& segment) { - return segment.key + ".g" + std::to_string(*segment.generation); +std::string MakeBigSegmentRef(std::string const& key, + std::uint64_t generation) { + return key + ".g" + std::to_string(generation); } // Evaluates membership in an unbounded (Big) segment. Returns true/false for a @@ -46,6 +48,7 @@ std::optional MatchBigSegment(Segment const& segment, EvaluationReason::BigSegmentsStatus::kNotConfigured); return false; } + std::uint64_t const generation = *segment.generation; // An absent or empty unboundedContextKind defaults to "user". ContextKind const kind = (segment.unboundedContextKind && @@ -81,7 +84,8 @@ std::optional MatchBigSegment(Segment const& segment, membership = stack.FindMembership(key); } - return membership->CheckMembership(MakeBigSegmentRef(segment)); + return membership->CheckMembership( + MakeBigSegmentRef(segment.key, generation)); } } // namespace