clang-tidy: Enable a clang-analyzer and readability check
This commit enables clang-analyzer-deadcode.DeadStores check
which indicates that there are variables in your code that are
assigned values but are never used beyond that assignment.
The readability-static-accessed-through-instance check verifies
when a static member of a class is accessed through an instance
of that class rather than through the class itself.
But here this check is capturing an error on "serviceName"
even when the member is a constant and not a static member.
So just ignoring this check in the function.
Change-Id: I18b60a0800870ac8394f5a0754fbbac0cfd18c36
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/.clang-tidy b/.clang-tidy
index 89403ad..e3c8194 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -119,6 +119,7 @@
clang-analyzer-cplusplus.SelfAssignment,
clang-analyzer-cplusplus.SmartPtrModeling,
clang-analyzer-cplusplus.VirtualCallModeling,
+clang-analyzer-deadcode.DeadStores,
clang-analyzer-fuchsia.HandleChecker,
clang-analyzer-nullability.NullPassedToNonnull,
clang-analyzer-nullability.NullReturnedFromNonnull,
@@ -251,6 +252,7 @@
readability-redundant-string-cstr,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
+readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-suspicious-call-argument,
diff --git a/software_manager.cpp b/software_manager.cpp
index d362abf..15f7dbe 100644
--- a/software_manager.cpp
+++ b/software_manager.cpp
@@ -13,9 +13,10 @@
auto path = std::string(SOFTWARE_OBJPATH) + "/bmc";
sdbusplus::async::context ctx;
sdbusplus::server::manager_t manager{ctx, path.c_str()};
- constexpr auto serviceName = "xyz.openbmc_project.Software.Manager";
- ctx.spawn([](sdbusplus::async::context& ctx) -> sdbusplus::async::task<> {
+ // NOLINTNEXTLINE(readability-static-accessed-through-instance)
+ ctx.spawn([=](sdbusplus::async::context& ctx) -> sdbusplus::async::task<> {
+ constexpr auto serviceName = "xyz.openbmc_project.Software.Manager";
ctx.request_name(serviceName);
co_return;
}(ctx));