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
39 changes: 39 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Checks: 'boost-*,bugprone-*,clang-diagnostic*,cppcoreguidelines-*,modernize-*,misc-*,performance-*,readability-*,-bugprone-easily-swappable-parameters,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-vararg,-modernize-use-trailing-return-type,-misc-include-cleaner,-misc-non-private-member-variables-in-classes'
WarningsAsErrors: "*"
HeaderFilterRegex: '.*\/(olp-cpp-sdk-core|olp-cpp-sdk-authentication|olp-cpp-sdk-dataservice-read|olp-cpp-sdk-dataservice-write)\/.*'
FormatStyle: "file"
CheckOptions:
- key: readability-function-cognitive-complexity.IgnoreMacros
value: true
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.MethodCase
value: CamelCase
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: readability-identifier-naming.EnumConstantCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantPrefix
value: k
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
20 changes: 19 additions & 1 deletion .github/workflows/psv_pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ jobs:
run: ./scripts/misc/cpplint_ci.sh
shell: bash

psv-linux-24-04-clang17-build-clang-tidy:
name: PSV.Linux.24.04.clang17.ClangTidy
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libboost-all-dev \
libcurl4-openssl-dev
shell: bash
- name: Run clang-tidy
run: ./scripts/misc/clang-tidy-17-check.sh
shell: bash

psv-linux-22-04-gcc9-build-test-codecov:
name: PSV.Linux.22.04.gcc9.Tests.CodeCov
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -377,4 +395,4 @@ jobs:
echo "Then run: git apply $CLANG_FORMAT_FILE"
exit 1
fi
shell: bash
shell: bash
2 changes: 1 addition & 1 deletion olp-cpp-sdk-authentication/src/Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Crypto::Sha256Digest ComputeSha256(const std::vector<unsigned char>& src) {
auto v3 = (unsigned char)value;
auto v2 = (unsigned char)(value >>= 8);
auto v1 = (unsigned char)(value >>= 8);
ret[j + 0] = (unsigned char)(value >>= 8);
ret[j + 0] = (unsigned char)(value >> 8);
ret[j + 1] = v1;
ret[j + 2] = v2;
ret[j + 3] = v3;
Expand Down
2 changes: 1 addition & 1 deletion olp-cpp-sdk-authentication/src/SignInResultImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ SignInResultImpl::SignInResultImpl(

// Extra response data if no errors reported
if (!HasError()) {
if (!IsValid()) {
if (!is_valid_) {
status_ = http::HttpStatusCode::SERVICE_UNAVAILABLE;
error_.message = Constants::ERROR_HTTP_SERVICE_UNAVAILABLE;
} else {
Expand Down
1 change: 1 addition & 0 deletions olp-cpp-sdk-authentication/src/TokenEndpointImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ client::CancellationToken TokenEndpointImpl::RequestToken(
properties.scope = scope_;
return auth_client_.SignInClient(
credentials_, properties,
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[callback](
const AuthenticationClient::SignInClientResponse& sign_in_response) {
if (!sign_in_response) {
Expand Down
3 changes: 3 additions & 0 deletions olp-cpp-sdk-dataservice-write/src/IndexLayerClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ client::CancellationToken IndexLayerClientImpl::DeleteIndexData(
auto cancel_context = std::make_shared<client::CancellationContext>();
auto self = shared_from_this();

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(op_id);
callback(DeleteIndexDataResponse(client::ApiError(
Expand Down Expand Up @@ -302,12 +303,14 @@ client::CancellationToken IndexLayerClientImpl::UpdateIndex(
auto self = shared_from_this();

auto op_id = tokenList_.GetNextId();
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(op_id);
callback(UpdateIndexResponse(client::ApiError(
client::ErrorCode::Cancelled, "Operation cancelled.", true)));
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto updateIndex_callback = [=](UpdateIndexResponse update_index_response) {
self->tokenList_.RemoveTask(op_id);
if (!update_index_response.IsSuccessful()) {
Expand Down
2 changes: 2 additions & 0 deletions olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ olp::client::CancellationToken StreamLayerClientImpl::Flush(
// invocation: one during execution phase and other when `Flush` is cancelled.
auto exec_started = std::make_shared<std::atomic_bool>(false);

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto task_context = client::TaskContext::Create(
[=](client::CancellationContext context) -> EmptyFlushApiResponse {
exec_started->exchange(true);
Expand Down Expand Up @@ -249,6 +250,7 @@ olp::client::CancellationToken StreamLayerClientImpl::Flush(
callback(responses);
return EmptyFlushApiResponse{};
},
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](EmptyFlushApiResponse /*response*/) {
// we don't need to notify user 2 times, cause we already invoke a
// callback in the execution function:
Expand Down
12 changes: 12 additions & 0 deletions olp-cpp-sdk-dataservice-write/src/VersionedLayerClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ olp::client::CancellationToken VersionedLayerClientImpl::GetBaseVersion(
auto cancel_context = std::make_shared<client::CancellationContext>();
auto id = tokenList_.GetNextId();

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(id);
callback(client::ApiError(client::ErrorCode::Cancelled,
"Operation cancelled.", true));
};

auto getBaseVersion_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](MetadataApi::CatalogVersionResponse response) {
self->tokenList_.RemoveTask(id);
if (!response.IsSuccessful()) {
Expand All @@ -247,12 +249,14 @@ olp::client::CancellationToken VersionedLayerClientImpl::GetBaseVersion(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto getBaseVersion_function = [=]() -> client::CancellationToken {
return MetadataApi::GetLatestCatalogVersion(*self->apiclient_metadata_, -1,
olp::porting::none,
getBaseVersion_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down Expand Up @@ -298,13 +302,15 @@ olp::client::CancellationToken VersionedLayerClientImpl::GetBatch(
auto cancel_context = std::make_shared<client::CancellationContext>();
auto id = tokenList_.GetNextId();

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(id);
callback(client::ApiError(client::ErrorCode::Cancelled,
"Operation cancelled.", true));
};

auto getPublication_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](GetPublicationResponse getPublicationResponse) {
self->tokenList_.RemoveTask(id);
if (!getPublicationResponse.IsSuccessful()) {
Expand All @@ -314,12 +320,14 @@ olp::client::CancellationToken VersionedLayerClientImpl::GetBatch(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto getPublication_function = [=]() -> client::CancellationToken {
return PublishApi::GetPublication(*self->apiclient_publish_, publicationId,
olp::porting::none,
getPublication_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down Expand Up @@ -567,6 +575,7 @@ client::CancellationToken VersionedLayerClientImpl::CheckDataExists(
auto id = tokenList_.GetNextId();

auto check_data_exists_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](CheckDataExistsResponse check_data_exists_response) {
self->tokenList_.RemoveTask(id);
if (!check_data_exists_response.IsSuccessful()) {
Expand All @@ -576,17 +585,20 @@ client::CancellationToken VersionedLayerClientImpl::CheckDataExists(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto check_data_exists_function = [=]() -> client::CancellationToken {
return BlobApi::checkBlobExists(*self->apiclient_blob_, layer_id,
data_handle, olp::porting::none,
check_data_exists_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [callback]() {
callback(client::ApiError(client::ErrorCode::Cancelled,
"Operation cancelled.", true));
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down
17 changes: 17 additions & 0 deletions olp-cpp-sdk-dataservice-write/src/VolatileLayerClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ client::CancellationToken VolatileLayerClientImpl::GetBaseVersion(
};

auto getBaseVersion_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](MetadataApi::CatalogVersionResponse response) {
self->tokenList_.RemoveTask(id);
if (!response.IsSuccessful()) {
Expand All @@ -209,12 +210,14 @@ client::CancellationToken VolatileLayerClientImpl::GetBaseVersion(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto getBaseVersion_function = [=]() -> client::CancellationToken {
return MetadataApi::GetLatestCatalogVersion(*self->apiclient_metadata_, -1,
olp::porting::none,
getBaseVersion_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down Expand Up @@ -264,6 +267,7 @@ client::CancellationToken VolatileLayerClientImpl::StartBatch(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto init_publication_function = [=]() -> client::CancellationToken {
model::Publication pub;
pub.SetLayerIds(request.GetLayers().value_or(std::vector<std::string>()));
Expand All @@ -275,12 +279,14 @@ client::CancellationToken VolatileLayerClientImpl::StartBatch(
init_publication_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(id);
callback(client::ApiError(client::ErrorCode::Cancelled,
"Operation cancelled.", true));
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down Expand Up @@ -426,6 +432,7 @@ client::CancellationToken VolatileLayerClientImpl::GetBatch(
};

auto getPublication_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](GetPublicationResponse getPublicationResponse) {
self->tokenList_.RemoveTask(id);
if (!getPublicationResponse.IsSuccessful()) {
Expand All @@ -435,12 +442,14 @@ client::CancellationToken VolatileLayerClientImpl::GetBatch(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto getPublication_function = [=]() -> client::CancellationToken {
return PublishApi::GetPublication(*self->apiclient_publish_, publicationId,
olp::porting::none,
getPublication_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down Expand Up @@ -572,13 +581,15 @@ client::CancellationToken VolatileLayerClientImpl::PublishToBatch(
auto self = shared_from_this();
auto id = tokenList_.GetNextId();

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(id);
callback(client::ApiError(client::ErrorCode::Cancelled,
"Operation cancelled.", true));
};

auto upload_partitions_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](UploadPartitionsResponse upload_partitions_response) {
self->tokenList_.RemoveTask(id);
if (!upload_partitions_response.IsSuccessful()) {
Expand All @@ -588,6 +599,7 @@ client::CancellationToken VolatileLayerClientImpl::PublishToBatch(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto upload_partitions_function = [=]() -> client::CancellationToken {
std::vector<model::PublishPartition> pub_partition_list;
for (const auto& partition_request : partitions) {
Expand All @@ -610,6 +622,7 @@ client::CancellationToken VolatileLayerClientImpl::PublishToBatch(
upload_partitions_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down Expand Up @@ -654,13 +667,15 @@ client::CancellationToken VolatileLayerClientImpl::CompleteBatch(
auto self = shared_from_this();
auto cancel_context = std::make_shared<client::CancellationContext>();
auto id = tokenList_.GetNextId();
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto cancel_function = [=]() {
self->tokenList_.RemoveTask(id);
callback(client::ApiError(client::ErrorCode::Cancelled,
"Operation cancelled.", true));
};

auto completePublication_callback =
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
[=](SubmitPublicationResponse submitPublicationResponse) {
self->tokenList_.RemoveTask(id);
if (!submitPublicationResponse.IsSuccessful()) {
Expand All @@ -670,12 +685,14 @@ client::CancellationToken VolatileLayerClientImpl::CompleteBatch(
}
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
auto completePublication_function = [=]() -> client::CancellationToken {
return PublishApi::SubmitPublication(*self->apiclient_publish_,
publicationId, olp::porting::none,
completePublication_callback);
};

// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks): false
cancel_context->ExecuteOrCancelled(
[=]() -> client::CancellationToken {
return self->InitApiClients(
Expand Down
24 changes: 24 additions & 0 deletions scripts/misc/clang-tidy-17-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -ex

BUILD_DIR="build-clang-tidy"

rm -rf "${BUILD_DIR}"
mkdir "${BUILD_DIR}"

cmake -S . -B "${BUILD_DIR}" -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=clang++-17 \
-DCMAKE_C_COMPILER=clang-17 \
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
-DOLP_SDK_ENABLE_TESTING=OFF \
-DOLP_SDK_BUILD_EXAMPLES=OFF

cmake --build "${BUILD_DIR}" -- -j"$(nproc)"

run-clang-tidy-17.py -p "${BUILD_DIR}" \
-config-file="${PWD}/.clang-tidy" \
"${PWD}/olp-cpp-sdk-core/.*" \
"${PWD}/olp-cpp-sdk-authentication/.*" \
"${PWD}/olp-cpp-sdk-dataservice-read/.*" \
"${PWD}/olp-cpp-sdk-dataservice-write/.*"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update copyright blocks in changed files
maybe added scripts should have it as well, check other scripts in the reposotory

Loading