From 41a7b9d19d2328e9a24bcb3defdc7635fc8f7de1 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:49:30 +0000 Subject: [PATCH] Refactor code --- app/backend/src/room/RoomManager.hpp | 1 + app/backend/src/room/User.hpp | 2 +- app/raspberry_pi/include/rplidar/RPLidar.cpp | 2 +- app/raspberry_pi/src/car/system/CarSystem.h | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/backend/src/room/RoomManager.hpp b/app/backend/src/room/RoomManager.hpp index 59ef14b6..a12464a4 100644 --- a/app/backend/src/room/RoomManager.hpp +++ b/app/backend/src/room/RoomManager.hpp @@ -48,6 +48,7 @@ std::mutex RoomManager::m_; std::map> RoomManager::rooms; RoomManager* RoomManager::instance() { + // cppcheck-suppress identicalInnerCondition if (pinstance == nullptr) { std::lock_guard lock(m_); if (pinstance == nullptr) { diff --git a/app/backend/src/room/User.hpp b/app/backend/src/room/User.hpp index 0822e96c..05d22773 100644 --- a/app/backend/src/room/User.hpp +++ b/app/backend/src/room/User.hpp @@ -23,9 +23,9 @@ class User const drogon::WebSocketConnectionPtr getConnection() const { return this->connection; } private: + const drogon::SubscriberID id; const std::string chat_room_name; const UserType type; - const drogon::SubscriberID id; const drogon::WebSocketConnectionPtr connection; std::string name; diff --git a/app/raspberry_pi/include/rplidar/RPLidar.cpp b/app/raspberry_pi/include/rplidar/RPLidar.cpp index 22b50137..d6a8a509 100644 --- a/app/raspberry_pi/include/rplidar/RPLidar.cpp +++ b/app/raspberry_pi/include/rplidar/RPLidar.cpp @@ -536,7 +536,7 @@ namespace rplidar { { int dsize = scanning.dsize; - if (maxBufMeas) + if (maxBufMeas != 0) { int dataInBuf = this->_serial->available(); if (dataInBuf > maxBufMeas) diff --git a/app/raspberry_pi/src/car/system/CarSystem.h b/app/raspberry_pi/src/car/system/CarSystem.h index 666a4ad0..2ae993ba 100644 --- a/app/raspberry_pi/src/car/system/CarSystem.h +++ b/app/raspberry_pi/src/car/system/CarSystem.h @@ -29,7 +29,7 @@ namespace car::system { void terminate(); void move(const MoveCommand& move_command); - void turn(const TurnCommand& move_command); + void turn(const TurnCommand& turn_command); private: std::unique_ptr lidar_device;