Enable readability-container-size-empty tests
This one is a little trivial, but it does help in readability.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 53d644d..0bf03cc 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -88,7 +88,7 @@
{
return "Operator";
}
- if ((role == "") || (role == "priv-noaccess"))
+ if (role.empty() || (role == "priv-noaccess"))
{
return "NoAccess";
}
@@ -108,7 +108,7 @@
{
return "priv-operator";
}
- if ((role == "NoAccess") || (role == ""))
+ if ((role == "NoAccess") || (role.empty()))
{
return "priv-noaccess";
}
@@ -1029,7 +1029,7 @@
}
if (serviceAddressList)
{
- if ((*serviceAddressList).size() == 0)
+ if (serviceAddressList->empty())
{
messages::propertyValueNotInList(asyncResp->res, "[]",
"ServiceAddress");
@@ -1038,7 +1038,7 @@
}
if (baseDNList)
{
- if ((*baseDNList).size() == 0)
+ if (baseDNList->empty())
{
messages::propertyValueNotInList(asyncResp->res, "[]",
"BaseDistinguishedNames");
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index fa9cc2f..34f6770 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -293,7 +293,7 @@
// password, which will likely cause bmcweb to crash on startup
// if this is not set on a post so not allowing the user to set
// value
- if (*optChallengePassword != "")
+ if (!optChallengePassword->empty())
{
messages::actionParameterNotSupported(
asyncResp->res, "GenerateCSR", "ChallengePassword");
@@ -355,7 +355,7 @@
certURI,
"/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"))
{
- if (optKeyUsage->size() == 0)
+ if (optKeyUsage->empty())
{
optKeyUsage->push_back("ServerAuthentication");
}
@@ -379,7 +379,7 @@
certURI,
"/redfish/v1/AccountService/LDAP/Certificates"))
{
- if (optKeyUsage->size() == 0)
+ if (optKeyUsage->empty())
{
optKeyUsage->push_back("ClientAuthentication");
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 8eb9821..7b67380 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -270,7 +270,7 @@
health->populate();
- if (connectionNames.size() < 1)
+ if (connectionNames.empty())
{
BMCWEB_LOG_ERROR << "Got 0 Connection names";
continue;
@@ -375,7 +375,7 @@
// so skip if it is empty
if (propertyName == "SparePartNumber")
{
- if (*value == "")
+ if (value->empty())
{
continue;
}
@@ -514,7 +514,7 @@
continue;
}
- if (connectionNames.size() < 1)
+ if (connectionNames.empty())
{
BMCWEB_LOG_ERROR << "Got 0 Connection names";
continue;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 0561c67..7c2da78 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -2130,7 +2130,7 @@
const EthernetInterfaceData& ethData,
const boost::container::flat_set<IPv4AddressData>&,
const boost::container::flat_set<IPv6AddressData>&) {
- if (success && ethData.vlan_id.size() != 0)
+ if (success && !ethData.vlan_id.empty())
{
parseInterfaceData(asyncResp->res.jsonValue,
parentIfaceId, ifaceId, ethData);
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 8c748f9..115bfee 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -232,7 +232,7 @@
if (regPrefixes && msgIds)
{
- if (regPrefixes->size() && msgIds->size())
+ if (!regPrefixes->empty() && !msgIds->empty())
{
messages::mutualExclusiveProperties(
asyncResp->res, "RegistryPrefixes", "MessageIds");
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index db9b5aa..76032b3 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -120,7 +120,7 @@
return;
}
- if (objInfo.size() == 0)
+ if (objInfo.empty())
{
// As noted above, this is an optional interface so just return
// if there is no instance found
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 3877541..41438cb 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1115,7 +1115,7 @@
boost::split(logEntryFields, entry, boost::is_any_of(","),
boost::token_compress_on);
// We need at least a MessageId to be valid
- if (logEntryFields.size() < 1)
+ if (logEntryFields.empty())
{
return 1;
}
@@ -1971,12 +1971,12 @@
}
// If vector is empty, that means skip value larger than total
// log count
- if (logEntries.size() == 0)
+ if (logEntries.empty())
{
asyncResp->res.jsonValue["Members@odata.count"] = logCount;
return;
}
- if (logEntries.size() > 0)
+ if (!logEntries.empty())
{
for (size_t i = 0; i < logEntries.size(); i++)
{
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index d450544..9a805f0 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -807,7 +807,7 @@
}
}
- if (profile.size() &&
+ if (!profile.empty() &&
(type == "PidControllers" || type == "FanControllers" ||
type == "StepwiseControllers"))
{
@@ -1821,7 +1821,7 @@
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find image!";
messages::internalError(aResp->res);
@@ -2099,7 +2099,7 @@
<< "D-Bus response error on GetSubTree " << ec;
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find bmc D-Bus object!";
return;
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 61c3c68..7b665eb 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -141,10 +141,10 @@
return;
}
asyncResp->res.jsonValue["NTP"]["NTPServers"] = ntpServers;
- if (hostName.empty() == false)
+ if (!hostName.empty())
{
std::string fqdn = hostName;
- if (domainNames.empty() == false)
+ if (!domainNames.empty())
{
fqdn += ".";
fqdn += domainNames[0];
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 78fa669..10655bf 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -217,7 +217,7 @@
messages::internalError(asyncResp->res);
return;
}
- if (*generationInUse == "")
+ if (generationInUse->empty())
{
// unknown, no need to handle
return;
@@ -303,7 +303,7 @@
"DeviceId";
std::string* property = std::get_if<std::string>(
&pcieDevProperties[devIDProperty]);
- if (property && !property->empty())
+ if (property != nullptr && !property->empty())
{
pcieFunctionList.push_back(
{{"@odata.id",
@@ -365,7 +365,7 @@
"Function" + function + "DeviceId";
if (std::string* property = std::get_if<std::string>(
&pcieDevProperties[devIDProperty]);
- property && property->empty())
+ property != nullptr && property->empty())
{
messages::resourceNotFound(asyncResp->res,
"PCIeFunction", function);
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 881bf1a..a51aafd 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -62,7 +62,7 @@
BMCWEB_LOG_ERROR << ec;
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find chassis!";
return;
@@ -183,7 +183,7 @@
callback(ec, 0);
return;
}
- if (resp.size() < 1)
+ if (resp.empty())
{
// Network Protocol Listen Response Elements is empty
boost::system::error_code ec1 =
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index a3f1c23..121223e 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1277,9 +1277,9 @@
}
size_t minNumNeeded =
- collection->size() > 0
- ? collection->size() - *allowedFailures
- : 0;
+ collection->empty()
+ ? 0
+ : collection->size() - *allowedFailures;
nlohmann::json& jResp =
sensorsAsyncResp->asyncResp->res
.jsonValue["Redundancy"];
@@ -2245,7 +2245,7 @@
<< "getPowerSupplyAttributes respHandler DBus error " << ec;
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find Power Supply Attributes!";
callback(inventoryItems);
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index f5e75e5..3e6f422 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -113,7 +113,7 @@
[asyncResp,
health](const boost::system::error_code ec,
const crow::openbmc_mapper::GetSubTreeType& subtree) {
- if (ec || !subtree.size())
+ if (ec || subtree.empty())
{
// doesn't have to be there
return;
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index e7f4f02..604f551 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -267,7 +267,7 @@
const std::vector<
std::pair<std::string, std::vector<std::string>>>&
connectionNames = object.second;
- if (connectionNames.size() < 1)
+ if (connectionNames.empty())
{
continue;
}
@@ -311,7 +311,7 @@
<< properties.size()
<< " Dimm properties.";
- if (properties.size() > 0)
+ if (!properties.empty())
{
for (const std::pair<
std::string,
@@ -1241,7 +1241,7 @@
// error occurs
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
// As noted above, this is an optional interface so just return
// if there is no instance found
@@ -1332,7 +1332,7 @@
messages::internalError(aResp->res);
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
messages::propertyValueNotInList(aResp->res, "ComputerSystem",
"TrustedModuleRequiredToBoot");
@@ -1661,7 +1661,7 @@
messages::internalError(aResp->res);
return;
}
- if (subtree.size() == 0)
+ if (subtree.empty())
{
BMCWEB_LOG_DEBUG << "Can't find system D-Bus object!";
messages::internalError(aResp->res);
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index f820e61..3137ab3 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -824,7 +824,7 @@
continue;
}
- if (obj.second.size() < 1)
+ if (obj.second.empty())
{
continue;
}
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index f617f4a..9333f61 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -87,7 +87,7 @@
{
const std::string* imageUrlValue =
std::get_if<std::string>(&value);
- if (imageUrlValue && !imageUrlValue->empty())
+ if (imageUrlValue != nullptr && !imageUrlValue->empty())
{
std::filesystem::path filePath = *imageUrlValue;
if (!filePath.has_filename())