summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-03-28 00:12:21 +0300
committerEd Tanous <ed@tanous.net>2024-04-01 20:29:16 +0300
commitddf3564e48bcee32dff1eff7a985a084be529615 (patch)
tree7d619694226e64631b0386b576b1c9c176b9c05d
parentd82b5e1f83a02ef9ccfe8d7072d215140451945b (diff)
downloadbmcweb-ddf3564e48bcee32dff1eff7a985a084be529615.tar.xz
Enable readability check
readability-avoid-nested-conditional-operator With one exception, we already pass this check. Update the log services code to make it pass, and update it to use the generated enums. Tested: Code inspection only. Change-Id: Ic80a7382beb0f541de4916d7b51e42ed5d5dc542 Signed-off-by: Ed Tanous <ed@tanous.net>
-rw-r--r--.clang-tidy1
-rw-r--r--redfish-core/lib/log_services.hpp14
2 files changed, 12 insertions, 3 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 7cb9ecdd8e..ca103f34cf 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -305,6 +305,7 @@ performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-avoid-const-params-in-decls,
+readability-avoid-nested-conditional-operator,
readability-braces-around-statements,
readability-const-return-type,
readability-container-contains,
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 24f0251ee1..4ea01e3531 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -2594,9 +2594,17 @@ static int
bmcJournalLogEntryJson["Id"] = bmcJournalLogEntryID;
bmcJournalLogEntryJson["Message"] = std::move(message);
bmcJournalLogEntryJson["EntryType"] = "Oem";
- bmcJournalLogEntryJson["Severity"] = severity <= 2 ? "Critical"
- : severity <= 4 ? "Warning"
- : "OK";
+ log_entry::EventSeverity severityEnum = log_entry::EventSeverity::OK;
+ if (severity <= 2)
+ {
+ severityEnum = log_entry::EventSeverity::Critical;
+ }
+ else if (severity <= 4)
+ {
+ severityEnum = log_entry::EventSeverity::Warning;
+ }
+
+ bmcJournalLogEntryJson["Severity"] = severityEnum;
bmcJournalLogEntryJson["OemRecordFormat"] = "BMC Journal Entry";
bmcJournalLogEntryJson["Created"] = std::move(entryTimeStr);
return 0;