Skip to content

Commit

Permalink
Various CPPLinter warnings fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PBrunot committed Aug 12, 2024
1 parent 1e9f4ca commit 85b0b72
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/BaseRfidWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace fabomatic
virtual auto selfTest() const -> bool = 0;
virtual auto reset() const -> void = 0;

virtual auto setDisabledUntil(std::optional<Tasks::time_point> t) -> void = 0;
virtual auto setDisabledUntil(const std::optional<Tasks::time_point> &t) -> void = 0;
};
} // namespace fabomatic
#endif // BASERFIDWRAPPER_HPP_
6 changes: 3 additions & 3 deletions include/BufferedMsg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace fabomatic
/// @brief Message that can be saved in Flash for future replay
struct BufferedMsg
{
std::string mqtt_message;
std::string mqtt_topic;
bool wait_for_answer;
std::string mqtt_message{};
std::string mqtt_topic{};
bool wait_for_answer = false;
BufferedMsg() = default;
BufferedMsg(const std::string &message, const std::string &topic, bool wait) : mqtt_message(message), mqtt_topic(topic), wait_for_answer{wait} {};
BufferedMsg(const BufferedMsg &source) = default;
Expand Down
2 changes: 1 addition & 1 deletion include/FabBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace fabomatic

auto configure(const SavedConfig &config) -> void; // Must be called before using the server
auto disconnect() -> void;
auto setChannel(int32_t channel) -> void;
auto setChannel(int16_t channel) -> void;

// Rule of 5 https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-five
FabBackend(const FabBackend &) = delete; // copy constructor
Expand Down
2 changes: 1 addition & 1 deletion include/RFIDWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace fabomatic

[[nodiscard]] auto getUid() const -> card::uid_t override;

[[nodiscard]] auto setDisabledUntil(std::optional<Tasks::time_point> delay) -> void override;
[[nodiscard]] auto setDisabledUntil(const std::optional<Tasks::time_point> &delay) -> void override;

/// @brief Returns the driver object for testing/simulation
Driver &getDriver();
Expand Down
1 change: 0 additions & 1 deletion include/card.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "conf.hpp"

#include "Logging.hpp"
#include <esp_mac.h>

namespace fabomatic::card
{
Expand Down
10 changes: 4 additions & 6 deletions src/FabBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,9 @@ namespace fabomatic
{
return true;
}
else
{
ESP_LOGW(TAG, "Failed to publish query %s", query.payload().data());
this->disconnect();
}

ESP_LOGW(TAG, "Failed to publish query %s", query.payload().data());
this->disconnect();
}

if (query.buffered())
Expand Down Expand Up @@ -580,7 +578,7 @@ namespace fabomatic
*
* @param channel The channel number.
*/
void FabBackend::setChannel(int32_t channel)
void FabBackend::setChannel(int16_t channel)
{
this->channel = channel;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LCDWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace fabomatic
void LCDWrapper::prettyPrint(const DisplayBuffer &buf,
const BoardInfo &bi) const
{
std::stringstream ss;
std::stringstream ss{};
ss << "/" << std::string(conf::lcd::COLS, '-') << "\\\r\n"; // LCD top

for (const auto &row : buf)
Expand Down
4 changes: 2 additions & 2 deletions src/MQTTtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace fabomatic::MQTTInterface
std::stringstream ss{};

// Get MAC address
const auto serial = esp32::esp_serial();
const auto serial = esp32::esp_serial_str();

ss << "{\"action\":\"alive\","
<< "\"version\":\"" << FABOMATIC_BUILD << "," << GIT_VERSION << "\","
Expand Down Expand Up @@ -148,4 +148,4 @@ namespace fabomatic::MQTTInterface
auto response = std::make_unique<SimpleResponse>(doc["request_ok"].as<bool>());
return response;
}
} // namespace fabomatic::MQTT
} // namespace fabomatic::MQTTInterface
2 changes: 1 addition & 1 deletion src/MachineConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace fabomatic
{
auto MachineConfig::toString() const -> const std::string
{
std::stringstream sstream;
std::stringstream sstream{};

sstream << "MachineConfig (ID:" << machine_id.id;
sstream << ", Name:" << machine_name;
Expand Down
2 changes: 1 addition & 1 deletion src/RFIDWrapper.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace fabomatic
}

template <typename Driver>
[[nodiscard]] auto RFIDWrapper<Driver>::setDisabledUntil(std::optional<Tasks::time_point> delay) -> void
[[nodiscard]] auto RFIDWrapper<Driver>::setDisabledUntil(const std::optional<Tasks::time_point> &delay) -> void
{
this->disabledUntil = delay;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace fabomatic::Tasks

auto Task::toString() const -> const std::string
{
std::stringstream ss;
std::stringstream ss{};
ss << "Task " << getId() << ", active=" << active
<< ",Period(ms)=" << period << ", Delay(ms)=" << delay
<< ",Last run=" << last_run.time_since_epoch()
Expand Down
4 changes: 2 additions & 2 deletions src/mock/MockMQTTBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace fabomatic
});
if (elem != secrets::cards::whitelist.end())
{
std::stringstream ss;
std::stringstream ss{};
const auto &[id, level, name] = *elem;
ss << "{\"request_ok\":true,\"is_valid\":" << (level != FabUser::UserLevel::Unknown ? "true" : "false")
<< ",\"level\":" << +static_cast<uint8_t>(level)
Expand All @@ -170,7 +170,7 @@ namespace fabomatic
}

// Still return a valid user
std::stringstream ss;
std::stringstream ss{};
ss << "{\"request_ok\":true,\"is_valid\":true,\"level\":" << +2
<< ",\"name\":\"User" << uid_str << "\"}";
return ss.str();
Expand Down

0 comments on commit 85b0b72

Please sign in to comment.