ros / bond_core

Maintains a bond (i.e. heart beat ) between ROS nodes and provides feedback when the bond is broken
http://www.ros.org/wiki/bond_core
35 stars 64 forks source link

reformat bondcpp for better readability #52

Open kejxu opened 5 years ago

kejxu commented 5 years ago

reformatting bondcpp code according to https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines for better readability

, 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

kejxu commented 5 years ago

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.