Skip to content

Commit

Permalink
Clean code from clang-tidy warnings/suggestions (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
jharmer95 authored Sep 28, 2021
1 parent 61d5440 commit 8cba8ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions include/rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace details
std::is_reference_v<
decltype(x)> && !std::is_const_v<std::remove_reference_t<decltype(x)>>)
{
x = std::move(y);
x = std::forward<decltype(y)>(y);
}
}(dest, std::get<Is>(src)),
0)... };
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace details

void set_err_mesg(const std::string& mesg) & { m_err_mesg = mesg; }

explicit operator bool() const { return m_err_mesg.empty(); }
virtual explicit operator bool() const { return m_err_mesg.empty(); }

const args_t& get_args() const& { return m_args; }
[[nodiscard]] args_t get_args() && { return std::move(m_args); }
Expand Down Expand Up @@ -331,7 +331,7 @@ class packed_func final : public details::packed_func_base<Args...>
///@note If an error occurred, the reason may be retrieved from the get_err_mesg() function
///@return true A return value exists and no error occurred
///@return false A return value does not exist AND/OR an error occurred
explicit operator bool() const
explicit operator bool() const override
{
return m_result.has_value() && details::packed_func_base<Args...>::operator bool();
}
Expand Down Expand Up @@ -430,7 +430,7 @@ class pack_adapter
///
///@param serial_obj Serial object to be modified
///@param mesg String to set as the error message
static void set_err_mesg(typename Serial::serial_t& serial_obj, std::string mesg);
static void set_err_mesg(typename Serial::serial_t& serial_obj, const std::string& mesg);
};

#if defined(RPC_HPP_SERVER_IMPL) || defined(RPC_HPP_MODULE_IMPL)
Expand Down
12 changes: 6 additions & 6 deletions include/rpc_adapters/rpc_bitsery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,23 @@ namespace adapters
// Borrowed from Bitsery library for compatibility
inline void write_length(bit_buffer& bytes, size_t size, size_t& index)
{
if (size < 0x80u)
if (size < 0x80U)
{
bytes.insert(bytes.begin() + index++, static_cast<uint8_t>(size));
}
else
{
if (size < 0x4000u)
if (size < 0x4000U)
{
bytes.insert(
bytes.begin() + index++, static_cast<uint8_t>((size >> 8) | 0x80u));
bytes.begin() + index++, static_cast<uint8_t>((size >> 8) | 0x80U));
bytes.insert(bytes.begin() + index++, static_cast<uint8_t>(size));
}
else
{
assert(size < 0x40000000u);
assert(size < 0x40000000U);
bytes.insert(
bytes.begin() + index++, static_cast<uint8_t>((size >> 24) | 0xC0u));
bytes.begin() + index++, static_cast<uint8_t>((size >> 24) | 0xC0U));

bytes.insert(bytes.begin() + index++, static_cast<uint8_t>(size >> 16));

Expand Down Expand Up @@ -489,7 +489,7 @@ inline std::string pack_adapter<adapters::bitsery_adapter>::get_func_name(

template<>
inline void pack_adapter<adapters::bitsery_adapter>::set_err_mesg(
adapters::bitsery::bit_buffer& serial_obj, const std::string mesg)
adapters::bitsery::bit_buffer& serial_obj, const std::string& mesg)
{
size_t index = 0;

Expand Down
4 changes: 2 additions & 2 deletions include/rpc_adapters/rpc_boost_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ inline std::string pack_adapter<adapters::boost_json_adapter>::get_func_name(

template<>
inline void pack_adapter<adapters::boost_json_adapter>::set_err_mesg(
adapters::boost_json::value_t& serial_obj, std::string mesg)
adapters::boost_json::value_t& serial_obj, const std::string& mesg)
{
assert(serial_obj.is_object());
auto& obj = serial_obj.as_object();
obj["err_mesg"] = std::move(mesg);
obj["err_mesg"] = mesg;
}
} // namespace rpc
4 changes: 2 additions & 2 deletions include/rpc_adapters/rpc_njson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ inline std::string pack_adapter<adapters::njson_adapter>::get_func_name(

template<>
inline void pack_adapter<adapters::njson_adapter>::set_err_mesg(
adapters::njson::njson_t& serial_obj, std::string mesg)
adapters::njson::njson_t& serial_obj, const std::string& mesg)
{
serial_obj["err_mesg"] = std::move(mesg);
serial_obj["err_mesg"] = mesg;
}
} // namespace rpc
6 changes: 3 additions & 3 deletions include/rpc_adapters/rpc_rapidjson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,18 +393,18 @@ inline std::string pack_adapter<adapters::rapidjson_adapter>::get_func_name(

template<>
inline void pack_adapter<adapters::rapidjson_adapter>::set_err_mesg(
adapters::rapidjson::doc_t& serial_obj, std::string mesg)
adapters::rapidjson::doc_t& serial_obj, const std::string& mesg)
{
auto& alloc = serial_obj.GetAllocator();

if (serial_obj.HasMember("err_mesg"))
{
serial_obj["HasMember"].SetString(std::move(mesg).c_str(), alloc);
serial_obj["HasMember"].SetString(mesg.c_str(), alloc);
}
else
{
adapters::rapidjson::value_t v;
v.SetString(std::move(mesg).c_str(), alloc);
v.SetString(mesg.c_str(), alloc);
serial_obj.AddMember("err_mesg", v, alloc);
}
}
Expand Down

0 comments on commit 8cba8ff

Please sign in to comment.