Skip to content

Commit

Permalink
fix codacy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
YanzhaoW committed Nov 17, 2024
1 parent 31181a2 commit 40dc934
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
12 changes: 5 additions & 7 deletions backend/srs/analysis/DataProcessManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace srs

// Getters:
template <DataDeserializeOptions option>
auto get_data() -> const auto&;
auto get_data() -> std::string_view;

auto get_struct_data() -> const auto& { return struct_deserializer_.data(); }

private:
SerializableMsgBuffer binary_data_;
Expand All @@ -48,19 +50,15 @@ namespace srs
};

template <DataDeserializeOptions option>
auto DataProcessManager::get_data() -> const auto&
auto DataProcessManager::get_data() -> std::string_view
{
if constexpr (option == raw)
{
return binary_data_.data();
}
else if constexpr (option == structure)
{
return struct_deserializer_.data();
}
else if constexpr (option == proto)
{
return std::string_view{ proto_serializer_.data() };
return proto_serializer_.data();
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions backend/srs/analysis/DataProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,34 +148,34 @@ namespace srs

void DataProcessor::update_monitor()
{
const auto& struct_data = data_processes_.get_data<DataProcessManager::structure>();
const auto& struct_data = data_processes_.get_struct_data();

total_processed_hit_numer_ += struct_data.hit_data.size();
monitor_.update(struct_data);
}

void DataProcessor::print_data()
{
const auto& export_data = data_processes_.get_data<DataProcessManager::structure>();
const auto& export_data = data_processes_.get_struct_data();
const auto& raw_data = data_processes_.get_data<DataProcessManager::raw>();
if (print_mode_ == print_raw)
{
spdlog::info("data: {:x}", fmt::join(raw_data, ""));
}
if (print_mode_ == print_header or print_mode_ == print_raw or print_mode_ == print_all)
{
spdlog::info("frame header: [ {} ]. Data size: {}", export_data.header, received_data_size_);
spdlog::info("{}. Data size: {}", export_data.header, received_data_size_);
}

if (print_mode_ == print_all)
{
for (const auto& hit_data : export_data.hit_data)
{
spdlog::info("Hit data: [ {} ]", hit_data);
spdlog::info("{}", hit_data);
}
for (const auto& marker_data : export_data.marker_data)
{
spdlog::info("Marker data: [ {} ]", marker_data);
spdlog::info("{}", marker_data);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion backend/srs/converters/ProtoSerializerBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace srs
, converter_{ converter }
{
}
[[nodiscard]] auto data() const -> const auto& { return output_data_; }
[[nodiscard]] auto data() const -> std::string_view { return output_data_; }

private:
std::string name_;
Expand Down
4 changes: 2 additions & 2 deletions backend/srs/converters/SerializableBuffer.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <srs/utils/CommonDefitions.hpp>
#include <algorithm>
#include <boost/asio/buffer.hpp>
#include <srs/utils/CommonAlias.hpp>
#include <zpp_bits.h>

namespace srs
Expand All @@ -29,7 +29,7 @@ namespace srs
return asio::buffer(data_);
}

[[nodiscard]] auto data() const -> const auto& { return data_; }
[[nodiscard]] auto data() const -> std::string_view { return std::string_view{ data_.data(), data_.size() }; }

void clear() { data_.clear(); }

Expand Down
6 changes: 3 additions & 3 deletions backend/srs/converters/StructDeserializer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <algorithm>
#include <srs/converters/StructDeserializer.hpp>
#include <bitset>
#include <srs/converters/StructDeserializer.hpp>

namespace srs
{
Expand Down Expand Up @@ -97,7 +97,6 @@ namespace srs
// thread safe
auto StructDeserializer::convert(std::string_view binary_data) -> std::size_t
{
auto translated_size = std::size_t{};
auto deserialize_to = zpp::bits::in{ binary_data, zpp::bits::endian::network{}, zpp::bits::no_size{} };

auto read_bytes = binary_data.size() * sizeof(BufferElementType);
Expand All @@ -115,7 +114,8 @@ namespace srs
deserialize_to(output_data_.header, receive_raw_data_).or_throw();
byte_reverse_data_sq();
translate_raw_data(output_data_);
translated_size = receive_raw_data_.size();

auto translated_size = receive_raw_data_.size();
receive_raw_data_.clear();

return translated_size;
Expand Down

0 comments on commit 40dc934

Please sign in to comment.