Skip to content

Commit 969d284

Browse files
author
Andrei Popescu
authored
Second batch of SonarCube reported issues fixed. (#1288)
This commit fixes some of SonarCube reported issues with major and minor levels including: - Effective move of passed by value parameters. - Moved ougth to be static methods to anonymous namespace. - Initialize variables and members before usage. Relates-To: OAM-1366 Signed-off-by: Andrei Popescu <[email protected]>
1 parent 95146d7 commit 969d284

File tree

11 files changed

+51
-58
lines changed

11 files changed

+51
-58
lines changed

olp-cpp-sdk-dataservice-read/src/TaskSink.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ namespace dataservice {
2626
namespace read {
2727
namespace {
2828
constexpr auto kLogTag = "TaskSink";
29-
}
29+
30+
void ExecuteTask(client::TaskContext task) { task.Execute(); }
31+
} // namespace
3032

3133
TaskSink::TaskSink(std::shared_ptr<thread::TaskScheduler> task_scheduler)
3234
: task_scheduler_(std::move(task_scheduler)),
@@ -93,8 +95,6 @@ bool TaskSink::ScheduleTask(client::TaskContext task, uint32_t priority) {
9395
return true;
9496
}
9597

96-
void TaskSink::ExecuteTask(client::TaskContext task) { task.Execute(); }
97-
9898
} // namespace read
9999
} // namespace dataservice
100100
} // namespace olp

olp-cpp-sdk-dataservice-read/src/TaskSink.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ class TaskSink {
7272

7373
bool ScheduleTask(client::TaskContext task, uint32_t priority);
7474

75-
void ExecuteTask(client::TaskContext task);
76-
7775
const std::shared_ptr<thread::TaskScheduler> task_scheduler_;
7876
const std::shared_ptr<client::PendingRequests> pending_requests_;
7977
std::mutex mutex_;

olp-cpp-sdk-dataservice-read/src/repositories/QuadTreeIndex.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2021 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,9 @@
2929
#include "BlobDataReader.h"
3030
#include "BlobDataWriter.h"
3131

32+
namespace olp {
33+
namespace dataservice {
34+
namespace read {
3235
namespace {
3336
constexpr auto kParentQuadsKey = "parentQuads";
3437
constexpr auto kSubQuadsKey = "subQuads";
@@ -70,11 +73,18 @@ olp::dataservice::read::QuadTreeIndex::IndexData ParseCommonIndexData(
7073
}
7174
return data;
7275
}
73-
} // namespace
7476

75-
namespace olp {
76-
namespace dataservice {
77-
namespace read {
77+
bool WriteIndexData(const QuadTreeIndex::IndexData& data,
78+
BlobDataWriter& writer) {
79+
bool success = writer.Write(data.version);
80+
success &= writer.Write(data.data_size);
81+
success &= writer.Write(data.compressed_data_size);
82+
success &= writer.Write(data.data_handle);
83+
success &= writer.Write(data.checksum);
84+
success &= writer.Write(data.additional_metadata);
85+
return success;
86+
}
87+
} // namespace
7888

7989
QuadTreeIndex::QuadTreeIndex(cache::KeyValueCache::ValueTypePtr data) {
8090
if (data == nullptr || data->empty()) {
@@ -158,17 +168,6 @@ bool QuadTreeIndex::ReadIndexData(QuadTreeIndex::IndexData& data,
158168
return success;
159169
}
160170

161-
bool QuadTreeIndex::WriteIndexData(const IndexData& data,
162-
BlobDataWriter& writer) {
163-
bool success = writer.Write(data.version);
164-
success &= writer.Write(data.data_size);
165-
success &= writer.Write(data.compressed_data_size);
166-
success &= writer.Write(data.data_handle);
167-
success &= writer.Write(data.checksum);
168-
success &= writer.Write(data.additional_metadata);
169-
return success;
170-
}
171-
172171
void QuadTreeIndex::CreateBlob(olp::geo::TileKey root, int depth,
173172
std::vector<IndexData> parents,
174173
std::vector<IndexData> subs) {

olp-cpp-sdk-dataservice-read/src/repositories/QuadTreeIndex.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2021 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -126,7 +126,6 @@ class QuadTreeIndex {
126126
return reinterpret_cast<const uint8_t*>(data_) + size_;
127127
}
128128

129-
bool WriteIndexData(const IndexData& data, BlobDataWriter& writer);
130129
bool ReadIndexData(IndexData& data, uint32_t offset) const;
131130

132131
DataHeader* data_ = nullptr;

olp-cpp-sdk-dataservice-write/include/olp/dataservice/write/generated/model/Index.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2021 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,15 +49,15 @@ enum class DATASERVICE_WRITE_API IndexType {
4949
/**
5050
* @brief The index value of the HERE tile type.
5151
*
52-
* Represents the tile ID in the HERE map tiling scheme.
52+
* Represents the tile ID in the HERE map tiling scheme.
5353
*/
5454
Heretile,
5555

56-
5756
/**
5857
* @brief The index value of the time window type.
5958
*
60-
* The minimum value is 10 minutes, and the maximum is 24 hours (1440 minutes).
59+
* The minimum value is 10 minutes, and the maximum is 24 hours (1440
60+
* minutes).
6161
*/
6262
TimeWindow,
6363

@@ -102,7 +102,7 @@ class DATASERVICE_WRITE_API IndexValue {
102102
/// Represents values that are not supported by the index layer.
103103
class DATASERVICE_WRITE_API UnsupportedIndexValue final : public IndexValue {
104104
public:
105-
/**
105+
/**
106106
* @brief Creates the `UnsupportedIndexValue` instance.
107107
*
108108
* @param type The`IndexType` instance.
@@ -199,9 +199,8 @@ class DATASERVICE_WRITE_API StringIndexValue final : public IndexValue {
199199
* @param stringValue The string value.
200200
* @param type The `IndexType` instance.
201201
*/
202-
StringIndexValue(std::string stringValue, IndexType type) : IndexValue(type) {
203-
stringValue_ = std::move(stringValue);
204-
}
202+
StringIndexValue(std::string stringValue, IndexType type)
203+
: IndexValue(type), stringValue_{std::move(stringValue)} {}
205204

206205
/**
207206
* @brief Gets the string value of the index layer.
@@ -239,9 +238,7 @@ class DATASERVICE_WRITE_API TimeWindowIndexValue final : public IndexValue {
239238
* @param type The `IndexType` instance.
240239
*/
241240
TimeWindowIndexValue(int64_t timeWindowValue, IndexType type)
242-
: IndexValue(type) {
243-
timeWindowValue_ = std::move(timeWindowValue);
244-
}
241+
: IndexValue(type), timeWindowValue_{std::move(timeWindowValue)} {}
245242

246243
/**
247244
* @brief Gets the time vindow value of the index layer.
@@ -251,7 +248,8 @@ class DATASERVICE_WRITE_API TimeWindowIndexValue final : public IndexValue {
251248
const int64_t& GetValue() const { return timeWindowValue_; }
252249

253250
/**
254-
* @brief Gets a mutable reference to the time window value of the index layer.
251+
* @brief Gets a mutable reference to the time window value of the index
252+
* layer.
255253
*
256254
* @return The mutable reference to the time window value.
257255
*/
@@ -276,9 +274,8 @@ class DATASERVICE_WRITE_API HereTileIndexValue final : public IndexValue {
276274
* @param hereTileValue The HERE tile value.
277275
* @param type The `IndexType` instance.
278276
*/
279-
HereTileIndexValue(int64_t hereTileValue, IndexType type) : IndexValue(type) {
280-
hereTileValue_ = std::move(hereTileValue);
281-
}
277+
HereTileIndexValue(int64_t hereTileValue, IndexType type)
278+
: IndexValue(type), hereTileValue_{std::move(hereTileValue)} {}
282279

283280
/**
284281
* @brief Gets the HERE tile value of the index layer.
@@ -329,7 +326,7 @@ class DATASERVICE_WRITE_API Index final {
329326
*/
330327
Index(std::string uuid,
331328
std::map<IndexName, std::shared_ptr<IndexValue>> indexFields)
332-
: id_(uuid), indexFields_(indexFields) {}
329+
: id_(std::move(uuid)), indexFields_(std::move(indexFields)) {}
333330

334331
private:
335332
boost::optional<std::string> checksum_;

olp-cpp-sdk-dataservice-write/src/CatalogSettings.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2021 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,8 +47,7 @@ class CatalogSettings {
4747
using LayerSettingsResult =
4848
client::ApiResponse<LayerSettings, client::ApiError>;
4949

50-
CatalogSettings(const client::HRN catalog,
51-
client::OlpClientSettings settings);
50+
CatalogSettings(client::HRN catalog, client::OlpClientSettings settings);
5251

5352
LayerSettingsResult GetLayerSettings(client::CancellationContext context,
5453
BillingTag billing_tag,

olp-cpp-sdk-dataservice-write/src/IndexLayerClient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ namespace dataservice {
2626
namespace write {
2727
IndexLayerClient::IndexLayerClient(client::HRN catalog,
2828
client::OlpClientSettings settings)
29-
: impl_(std::make_shared<IndexLayerClientImpl>(catalog, settings)) {}
29+
: impl_(std::make_shared<IndexLayerClientImpl>(std::move(catalog),
30+
std::move(settings))) {}
3031

3132
void IndexLayerClient::CancelPendingRequests() {
3233
impl_->CancelPendingRequests();

olp-cpp-sdk-dataservice-write/src/IndexLayerClientImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2021 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,9 +47,9 @@ namespace write {
4747

4848
IndexLayerClientImpl::IndexLayerClientImpl(client::HRN catalog,
4949
client::OlpClientSettings settings)
50-
: catalog_(catalog),
51-
catalog_settings_(catalog, settings),
52-
settings_(settings),
50+
: catalog_(std::move(catalog)),
51+
catalog_settings_(catalog_, settings),
52+
settings_(std::move(settings)),
5353
apiclient_config_(nullptr),
5454
apiclient_blob_(nullptr),
5555
apiclient_index_(nullptr),

olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ constexpr int64_t kTwentyMib = 20971520; // 20 MiB
6262
StreamLayerClientImpl::StreamLayerClientImpl(
6363
client::HRN catalog, StreamLayerClientSettings client_settings,
6464
client::OlpClientSettings settings)
65-
: catalog_(catalog),
66-
settings_(settings),
67-
catalog_settings_(catalog, settings),
65+
: catalog_(std::move(catalog)),
66+
settings_(std::move(settings)),
67+
catalog_settings_(catalog_, settings_),
6868
cache_(settings_.cache),
6969
cache_mutex_(),
7070
stream_client_settings_(std::move(client_settings)),

olp-cpp-sdk-dataservice-write/src/VersionedLayerClientImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2021 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,9 +47,9 @@ namespace write {
4747

4848
VersionedLayerClientImpl::VersionedLayerClientImpl(
4949
client::HRN catalog, client::OlpClientSettings settings)
50-
: catalog_(catalog),
51-
settings_(settings),
52-
catalog_settings_(catalog, settings),
50+
: catalog_(std::move(catalog)),
51+
settings_(std::move(settings)),
52+
catalog_settings_(catalog_, settings_),
5353
apiclient_blob_(nullptr),
5454
apiclient_config_(nullptr),
5555
apiclient_metadata_(nullptr),

0 commit comments

Comments
 (0)