Skip to content

Commit

Permalink
Merge branch 'BehaviorTree:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Aglargil authored Feb 25, 2025
2 parents d8ca1f1 + aa085b7 commit 0eaf363
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/sonarcube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Sonarcube Scan
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install Build Wrapper
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libzmq3-dev libsqlite3-dev
- name: Install googletest
uses: Bacondish2023/setup-googletest@v1

- name: Run Build Wrapper
run: |
mkdir build
cmake -S . -B build
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
with:
args: >
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ else()
add_definitions(-Wpedantic -fno-omit-frame-pointer)
endif()

# create compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


#---- project configuration ----
option(BTCPP_SHARED_LIBS "Build shared libraries" ON)
Expand Down
2 changes: 1 addition & 1 deletion include/behaviortree_cpp/bt_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Tree
[[nodiscard]] Blackboard::Ptr rootBlackboard();

//Call the visitor for each node of the tree.
void applyVisitor(const std::function<void(const TreeNode*)>& visitor);
void applyVisitor(const std::function<void(const TreeNode*)>& visitor) const;

//Call the visitor for each node of the tree.
void applyVisitor(const std::function<void(TreeNode*)>& visitor);
Expand Down
9 changes: 5 additions & 4 deletions include/behaviortree_cpp/utils/convert_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ inline void checkTruncation(const From& from)
if constexpr(std::is_integral_v<From> && std::is_floating_point_v<To>)
{
// Check if value can be represented exactly in the target type
To as_float = static_cast<To>(from);
From back_conv = static_cast<From>(as_float);
if(back_conv != from)
constexpr auto max_exact = (1LL << std::numeric_limits<double>::digits) - 1;
if(from > max_exact || from < -max_exact)
{
throw std::runtime_error("Loss of precision in conversion to floating point");
throw std::runtime_error("Loss of precision when converting a large integer number "
"to floating point:" +
std::to_string(from));
}
}
// Handle floating point to integer
Expand Down
13 changes: 13 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sonar.projectKey=BehaviorTree_BehaviorTree.CPP
sonar.organization=behaviortree

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=BehaviorTree.CPP
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
2 changes: 1 addition & 1 deletion src/bt_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Blackboard::Ptr Tree::rootBlackboard()
return {};
}

void Tree::applyVisitor(const std::function<void(const TreeNode*)>& visitor)
void Tree::applyVisitor(const std::function<void(const TreeNode*)>& visitor) const
{
BT::applyRecursiveVisitor(static_cast<const TreeNode*>(rootNode()), visitor);
}
Expand Down

0 comments on commit 0eaf363

Please sign in to comment.