refactor: Fix readability-simplify-boolean-expr

This commit is contained in:
Lars Toenning
2025-10-25 22:45:55 +02:00
parent 469d9b8421
commit 7579ce8ba4
19 changed files with 22 additions and 37 deletions

View File

@@ -280,8 +280,7 @@ namespace swift::misc::aviation
// allow 2 chars for special codes like "VV"
if (airline.length() < 2 || airline.length() > 5) { return false; }
const auto chars = makeRange(airline.begin(), airline.end());
if (chars.containsBy([](QChar c) { return !c.isUpper() && !c.isDigit(); })) { return false; }
return true;
return !chars.containsBy([](QChar c) { return !c.isUpper() && !c.isDigit(); });
}
bool CAirlineIcaoCode::isValidIataCode(const QString &iataCode)

View File

@@ -294,7 +294,7 @@ namespace swift::misc::aviation
if (msgs) { msgs->push_back(CStatusMessage(this).validationError(u"Altitude NULL value")); }
return false;
}
if (!(this->getReferenceDatum() == FlightLevel || this->getReferenceDatum() == MeanSeaLevel))
if (this->getReferenceDatum() != FlightLevel && this->getReferenceDatum() != MeanSeaLevel)
{
if (msgs) { msgs->push_back(CStatusMessage(this).validationError(u"Altitude, must be FL or MSL")); }
return false;

View File

@@ -265,8 +265,7 @@ namespace swift::misc::network
bool CNetworkUtils::looksLikePhpErrorMessage(const QString &errorMessage)
{
if (errorMessage.length() < 50) { return false; }
if (errorMessage.contains("xdebug", Qt::CaseInsensitive)) { return true; }
return false;
return errorMessage.contains("xdebug", Qt::CaseInsensitive);
}
const QString &CNetworkUtils::networkOperationToString(QNetworkAccessManager::Operation operation)

View File

@@ -113,13 +113,11 @@ namespace swift::misc::network
if (this->getSenderCallsign() != textMessage.getSenderCallsign()) { return false; }
if (this->isRadioMessage() && textMessage.isRadioMessage())
{
if (this->getFrequency() != textMessage.getFrequency()) { return false; }
return true;
return this->getFrequency() == textMessage.getFrequency();
}
else if (this->isPrivateMessage() && textMessage.isPrivateMessage())
{
if (this->getRecipientCallsign() != textMessage.getRecipientCallsign()) { return false; }
return true;
return this->getRecipientCallsign() == textMessage.getRecipientCallsign();
}
return false;
}

View File

@@ -32,10 +32,7 @@ namespace swift::misc::simulation::fscommon
quint32 remainder = 0, quotient = 0, result = 0;
remainder = num % divider;
quotient = num / divider;
if (!(quotient == 0 && remainder == 0))
{
result += hornerScheme(quotient, divider, factor) * factor + remainder;
}
if (quotient != 0 || remainder != 0) { result += hornerScheme(quotient, divider, factor) * factor + remainder; }
return result;
}
} // namespace swift::misc::simulation::fscommon

View File

@@ -390,7 +390,7 @@ namespace swift::misc
auto object = json.object();
json.setObject(it->mergeToMemoizedJson(object));
if (!(file.seek(0) && file.resize(0) && file.write(json.toJson()) > 0 && file.checkedClose()))
if (!file.seek(0) || !file.resize(0) || file.write(json.toJson()) <= 0 || !file.checkedClose())
{
return CStatusMessage(this).error(u"Failed to write to %1: %2")
<< file.fileName() << file.errorString();