add clang-tidy
This commit implements a clang-tidy file, and makes some changes to get
it to pass. Most changes are naming or mechanical in nature.
Tested:
Clang-tidy now passes.
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: Ia441e4801b6c8725421d160c531c5df141f255d4
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 2e7442d..25e5739 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -14,11 +14,10 @@
// limitations under the License.
*/
-#include "PwmSensor.hpp"
-#include "TachSensor.hpp"
-#include "Utils.hpp"
-#include "VariantVisitors.hpp"
-
+#include <PwmSensor.hpp>
+#include <TachSensor.hpp>
+#include <Utils.hpp>
+#include <VariantVisitors.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/container/flat_map.hpp>
@@ -40,7 +39,7 @@
#include <variant>
#include <vector>
-static constexpr bool DEBUG = false;
+static constexpr bool debug = false;
namespace fs = std::filesystem;
@@ -77,7 +76,7 @@
{
return FanTypes::aspeed;
}
- else if (boost::ends_with(canonical, "f0103000.pwm-fan-controller"))
+ if (boost::ends_with(canonical, "f0103000.pwm-fan-controller"))
{
return FanTypes::nuvoton;
}
@@ -88,13 +87,13 @@
void createRedundancySensor(
const boost::container::flat_map<std::string, std::unique_ptr<TachSensor>>&
sensors,
- std::shared_ptr<sdbusplus::asio::connection> conn,
+ const std::shared_ptr<sdbusplus::asio::connection>& conn,
sdbusplus::asio::object_server& objectServer)
{
conn->async_method_call(
[&objectServer, &sensors](boost::system::error_code& ec,
- const ManagedObjectType managedObj) {
+ const ManagedObjectType& managedObj) {
if (ec)
{
std::cerr << "Error calling entity manager \n";
@@ -182,7 +181,7 @@
std::string link =
fs::read_symlink(directory / "device").filename();
- size_t findDash = link.find("-");
+ size_t findDash = link.find('-');
if (findDash == std::string::npos ||
link.size() <= findDash + 1)
{
@@ -235,7 +234,7 @@
sensorData = &(sensor.second);
break;
}
- else if (fanType == FanTypes::i2c)
+ if (fanType == FanTypes::i2c)
{
auto findBus = baseConfiguration->second.find("Bus");
auto findAddress =
@@ -471,7 +470,7 @@
/* we were canceled*/
return;
}
- else if (ec)
+ if (ec)
{
std::cerr << "timer error\n";
return;