Skip to content

Commit

Permalink
Clang tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed May 1, 2024
1 parent 9cc2525 commit 3a6fa59
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 84 deletions.
29 changes: 16 additions & 13 deletions backend/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
Checks: "*,
-abseil-*,
-altera-*,
-android-*,
-fuchsia-*,
-google-*,
-llvm*,
-modernize-use-trailing-return-type,
-zircon-*,
-readability-else-after-return,
-readability-static-accessed-through-instance,
-readability-avoid-const-params-in-decls,
-cppcoreguidelines-non-private-member-variables-in-classes,
-misc-non-private-member-variables-in-classes"
-altera-*,
-android-*,
-fuchsia-*,
-google-*,
-llvm*,
-modernize-use-trailing-return-type,
-zircon-*,
-readability-else-after-return,
-readability-static-accessed-through-instance,
-readability-avoid-const-params-in-decls,
-cppcoreguidelines-non-private-member-variables-in-classes,
-misc-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-magic-numbers,
-readability-magic-numbers,
-unused-includes"

WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Helpers {
return RadioSimulation::round8_33kHzChannel(frequency);
}

static void CallbackWithError(std::string message)
static void CallbackWithError(const std::string& message)
{
std::lock_guard<std::mutex> lock(errorCallbackMutex);
if (!callbackAvailable) {
Expand Down
24 changes: 17 additions & 7 deletions backend/src/RemoteData.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Poco/Timer.h>
#include <absl/strings/match.h>
#include <absl/strings/str_split.h>
#include <cstddef>
#include <httplib.h>
#include <quill/Quill.h>
#include <quill/detail/LogMacros.h>
Expand All @@ -13,23 +14,30 @@ class RemoteData {

public:
RemoteData()
: timer(3 * 1000, TIMER_CALLBACK_INTERVAL_SEC * 1000)
: timer(static_cast<long>(3 * 1000), static_cast<long>(TIMER_CALLBACK_INTERVAL_SEC * 1000))
, slurperCli(SLURPER_BASE_URL)
{
timer.start(Poco::TimerCallback<RemoteData>(*this, &RemoteData::onTimer));
}

RemoteData(const RemoteData&) = delete;
RemoteData(RemoteData&&) = delete;
RemoteData& operator=(const RemoteData&) = delete;
RemoteData& operator=(RemoteData&&) = delete;
~RemoteData() { timer.stop(); }

protected:
void onTimer(Poco::Timer& timer)
void onTimer(Poco::Timer& /*timer*/)
{
auto slurperData = getSlurperData();

auto previousCallsign = UserSession::callsign;

auto isConnected = parseSlurper(slurperData);
updateSessionStatus(previousCallsign, isConnected);
try {
auto isConnected = parseSlurper(slurperData);
updateSessionStatus(previousCallsign, isConnected);
} catch (const std::exception& ex) {
LOG_ERROR(logger, "Error while parsing slurper data: {}", ex.what());
}
}

std::string getSlurperData()
Expand All @@ -40,7 +48,7 @@ class RemoteData {

auto res = slurperCli.Get(SLURPER_DATA_ENDPOINT + std::string("?cid=") + UserSession::cid);

if (!res || res->status != 200) {
if (!res || res->status != httplib::StatusCode::OK_200) {
// Notify the client the slurper is offline
RemoteDataStatus::isSlurperAvailable = false;
LOG_ERROR(logger, "Slurper is offline {}", res->status);
Expand All @@ -55,6 +63,7 @@ class RemoteData {
return res->body;
}

// NOLINTNEXTLINE
bool parseSlurper(const std::string& sluper_data)
{
if (sluper_data.empty()) {
Expand Down Expand Up @@ -111,6 +120,7 @@ class RemoteData {
}

res3.erase(std::remove(res3.begin(), res3.end(), '.'), res3.end());
// NOLINTNEXTLINE Handled above in the try catch block
int u334 = std::atoi(res3.c_str()) * 1000;
int k422 = std::stoi(res2, nullptr, 16) == 10 && pYx ? 1 : 0;

Expand All @@ -131,7 +141,7 @@ class RemoteData {
return true;
}

void updateSessionStatus(std::string previousCallsign, bool isConnected)
static void updateSessionStatus(std::string previousCallsign, bool isConnected)
{
if (UserSession::isConnectedToTheNetwork && UserSession::callsign != previousCallsign && !previousCallsign.empty() && isConnected && mClient->IsVoiceConnected()) {
LOG_INFO(logger,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

constexpr semver::version VERSION = semver::version { 1, 0, 2, semver::prerelease::beta, 2 };

static const std::string CLIENT_NAME = std::string("TrackAudio-") + VERSION.to_string();
const std::string CLIENT_NAME = std::string("TrackAudio-") + VERSION.to_string();

static Napi::ThreadSafeFunction callbackRef;
static bool callbackAvailable = false;
Expand Down
Loading

0 comments on commit 3a6fa59

Please sign in to comment.