bond_core
bond_core copied to clipboard
reformat bondcpp for better readability
trafficstars
reformatting bondcpp code according to https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines for better readability
- indent with 4 spaces
- place each function call parameter on separate line if they are broken into multiple lines
- apply consistent coding style, this also provides clearer representation of a variable's type upon inspection
- use
type& nameovertype &name, the actual type ofnameistype& - use
type* nameovertype *name, the actual type ofnameistype*
- use
, and use early return for a clearer representation of logic:
void Bond::bondStatusCB(msg)
{
if (msg->id == id_ && msg->instance_id != instance_id_)
{
// action
}
}
has been changed to
void Bond::bondStatusCB(msg)
{
if (msg->id != id_)
{
// filter out heartbeat from other bonds
return;
}
if (msg->instance_id == instance_id_)
{
// filter out heartbeat from this bond
return;
}
// action
}
this also reduces the number of layers in code, providing better readability
kinetic build was showing this error message:
error: ‘>>’ should be ‘> >’ within a nested template argument list
while melodic builds fine
afaik, this is unnecessary as long as >> is not actually overridden, that's probably why melodic build was okay (since it uses a newer version of g++ compiler). However, this does not seem like something that has enough priority to be considered at the point. Changing >> to > > in favor of kinetic build.