Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ repos:
entry: ./run_clang_tidy_hook.sh
language: script
files: \.(cpp|hpp|h)$
exclude: ^3rdparty/|^include/behaviortree_cpp/contrib/|^include/behaviortree_cpp/scripting/
exclude: ^3rdparty/|^include/behaviortree_cpp/contrib/|^include/behaviortree_cpp/scripting/|^include/behaviortree_cpp/flatbuffers/|^examples/|^tools/|^fuzzing/|^tests/gtest_async_action_node\.cpp$|^tests/gtest_logger_zmq\.cpp$|^tests/include/environment\.h$|^tests/gtest_groot2_publisher\.cpp$

# Spell check
- repo: https://github.com/codespell-project/codespell
Expand Down
12 changes: 9 additions & 3 deletions examples/ex01_wrap_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Point3D convertFromString(StringView key)
}
else
{
Point3D output;
Point3D output{};
output.x = convertFromString<double>(parts[0]);
output.y = convertFromString<double>(parts[1]);
output.z = convertFromString<double>(parts[2]);
Expand All @@ -49,7 +49,11 @@ Point3D convertFromString(StringView key)
} // namespace BT

// clang-format off
static const char* xml_text = R"(

namespace
{

const char* xml_text = R"(

<root BTCPP_format="4">
<BehaviorTree>
Expand All @@ -58,6 +62,8 @@ static const char* xml_text = R"(
</root>
)";

} // namespace

// clang-format on

int main()
Expand All @@ -68,7 +74,7 @@ int main()

// Here we use a lambda that captures the reference of move_to
auto MoveToWrapperWithLambda = [&move_to](TreeNode& parent_node) -> NodeStatus {
Point3D goal;
Point3D goal{};
// thanks to paren_node, you can access easily the input and output ports.
parent_node.getInput("goal", goal);

Expand Down
9 changes: 7 additions & 2 deletions examples/t04_reactive_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ using namespace BT;

// clang-format off

static const char* xml_text_sequence = R"(
namespace
{

const char* xml_text_sequence = R"(

<root BTCPP_format="4" >

Expand All @@ -30,7 +33,7 @@ static const char* xml_text_sequence = R"(
</root>
)";

static const char* xml_text_reactive = R"(
const char* xml_text_reactive = R"(

<root BTCPP_format="4" >

Expand All @@ -48,6 +51,8 @@ static const char* xml_text_reactive = R"(
</root>
)";

} // namespace

// clang-format on

using namespace DummyNodes;
Expand Down
11 changes: 8 additions & 3 deletions examples/t07_load_multiple_xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

// clang-format off

static const char* xml_text_main = R"(
namespace
{

const char* xml_text_main = R"(
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence>
Expand All @@ -20,20 +23,22 @@ static const char* xml_text_main = R"(
</BehaviorTree>
</root> )";

static const char* xml_text_subA = R"(
const char* xml_text_subA = R"(
<root BTCPP_format="4">
<BehaviorTree ID="SubA">
<SaySomething message="Executing SubA" />
</BehaviorTree>
</root> )";

static const char* xml_text_subB = R"(
const char* xml_text_subB = R"(
<root BTCPP_format="4">
<BehaviorTree ID="SubB">
<SaySomething message="Executing SubB" />
</BehaviorTree>
</root> )";

} // namespace

// clang-format on

using namespace BT;
Expand Down
8 changes: 7 additions & 1 deletion examples/t09_scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
using namespace BT;

// clang-format off
static const char* xml_text = R"(

namespace
{

const char* xml_text = R"(
<root BTCPP_format="4">
<BehaviorTree>
<Sequence>
Expand All @@ -24,6 +28,8 @@ static const char* xml_text = R"(
</root>
)";

} // namespace

// clang-format on

int main()
Expand Down
14 changes: 9 additions & 5 deletions examples/t11_groot_howto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct Position2D
// the object to/from JSON.
// You still need to call BT::RegisterJsonDefinition<Position2D>()
// in main()
// NOLINTNEXTLINE(misc-use-internal-linkage)
BT_JSON_CONVERTER(Position2D, pos)
{
add_field("x", &pos.x);
Expand All @@ -39,6 +40,7 @@ struct Waypoint
double speed = 1.0;
};

// NOLINTNEXTLINE(misc-use-internal-linkage)
BT_JSON_CONVERTER(Waypoint, wp)
{
add_field("name", &wp.name);
Expand Down Expand Up @@ -70,6 +72,7 @@ class UpdatePosition : public BT::SyncActionNode

// Helper to generate random offset [-range, +range]
auto randOffset = [](double range) {
// NOLINTNEXTLINE(cert-msc30-c,cert-msc50-cpp,concurrency-mt-unsafe)
return (static_cast<double>(std::rand()) / RAND_MAX - 0.5) * 2.0 * range;
};

Expand Down Expand Up @@ -120,8 +123,9 @@ class UpdatePosition : public BT::SyncActionNode
};

// clang-format off

static const char* xml_text = R"(
namespace
{
const char* xml_text = R"(
<root BTCPP_format="4">

<BehaviorTree ID="MainTree">
Expand Down Expand Up @@ -150,7 +154,7 @@ static const char* xml_text = R"(

</root>
)";

} // namespace
// clang-format on

int main()
Expand All @@ -165,7 +169,7 @@ int main()
// Groot2 editor requires a model of your registered Nodes.
// You don't need to write that by hand, it can be automatically
// generated using the following command.
const std::string xml_models = BT::writeTreeNodesModelXML(factory);
[[maybe_unused]] const std::string xml_models = BT::writeTreeNodesModelXML(factory);

factory.registerBehaviorTreeFromText(xml_text);

Expand All @@ -191,7 +195,7 @@ int main()
BT::FileLogger2 logger2(tree, "t11_groot_howto.btlog");
BT::MinitraceLogger minilog(tree, "minitrace.json");

while(1)
while(true)
{
std::cout << "Start" << std::endl;
cross_door.reset();
Expand Down
7 changes: 5 additions & 2 deletions examples/t14_subtree_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ using namespace BT;
*/

// clang-format off
static const char* xml_subtree = R"(
namespace
{
const char* xml_subtree = R"(
<root BTCPP_format="4">

<TreeNodesModel>
Expand All @@ -48,7 +50,7 @@ static const char* xml_subtree = R"(
* remapped. We will use the default values for the other two.
*/

static const char* xml_maintree = R"(
const char* xml_maintree = R"(
<root BTCPP_format="4">

<BehaviorTree ID="MainTree">
Expand All @@ -62,6 +64,7 @@ static const char* xml_maintree = R"(

</root>
)";
} // namespace

// clang-format on

Expand Down
9 changes: 5 additions & 4 deletions examples/t15_nodes_mocking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include "behaviortree_cpp/bt_factory.h"

// clang-format off

static const char* xml_text = R"(
namespace
{
const char* xml_text = R"(
<root BTCPP_format="4">

<BehaviorTree ID="MainTree">
Expand Down Expand Up @@ -33,7 +34,7 @@ static const char* xml_text = R"(

</root>
)";

} // namespace
// clang-format on

/**
Expand All @@ -44,7 +45,7 @@ static const char* xml_text = R"(
* @return
*/

int main(int argc, char** argv)
int main(int /*argc*/, char** /*argv*/)
{
using namespace DummyNodes;
BT::BehaviorTreeFactory factory;
Expand Down
6 changes: 4 additions & 2 deletions examples/t16_global_blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ using namespace BT;
*/

// clang-format off
static const char* xml_main = R"(
namespace
{
const char* xml_main = R"(
<root BTCPP_format="4">

<BehaviorTree ID="MainTree">
Expand All @@ -43,7 +45,7 @@ static const char* xml_main = R"(
</BehaviorTree>
</root>
)";

} // namespace
// clang-format on

class PrintNumber : public BT::SyncActionNode
Expand Down
12 changes: 9 additions & 3 deletions examples/t18_waypoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PrintNumber : public SyncActionNode

NodeStatus tick() override
{
double value;
double value = 0.0;
if(getInput("value", value))
{
std::cout << "PrintNumber: " << value << "\n";
Expand Down Expand Up @@ -81,7 +81,7 @@ class UseWaypoint : public ThreadedAction

NodeStatus tick() override
{
Pose2D wp;
Pose2D wp{};
if(getInput("waypoint", wp))
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Expand All @@ -101,7 +101,11 @@ class UseWaypoint : public ThreadedAction
};

// clang-format off
static const char* xml_tree = R"(

namespace
{

const char* xml_tree = R"(
<root BTCPP_format="4" >
<BehaviorTree ID="TreeA">
<Sequence>
Expand All @@ -118,6 +122,8 @@ static const char* xml_tree = R"(
</root>
)";

} // namespace

// clang-format on

int main()
Expand Down
14 changes: 9 additions & 5 deletions fuzzing/script_fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
env.vars->set("result", result);

BT::Any read_back;
env.vars->get("result", read_back);
(void)env.vars->get("result", read_back);
}
catch(const BT::RuntimeError&) // NOLINT(bugprone-empty-catch)
{
// Intentionally empty - fuzzer expects exceptions
}
catch(const BT::RuntimeError&)
{}
}
}

BT::ParseScriptAndExecute(env, script);
}
catch(const std::exception&)
{}
catch(const std::exception&) // NOLINT(bugprone-empty-catch)
{
// Intentionally empty - fuzzer expects exceptions
}

return 0;
}
Loading
Loading