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

@@ -47,6 +47,7 @@ Checks: >
readability-redundant-member-init,
cppcoreguidelines-init-variables,
readability-static-accessed-through-instance,
readability-simplify-boolean-expr,
CheckOptions:
- key: readability-identifier-naming.ClassCase

View File

@@ -405,9 +405,7 @@ namespace swift::core
if (CBuildConfig::isLocalDeveloperDebugBuild()) { return true; }
const CDistribution d(this->getOwnDistribution());
if (d.isRestricted() && this->isSet(m_cmdDevelopment)) { return true; }
return false;
return d.isRestricted() && this->isSet(m_cmdDevelopment);
}
CStatusMessage CApplication::initLocalSettings()

View File

@@ -53,7 +53,6 @@ namespace swift::core::context
bool IContextSimulator::isSimulatorSimulating() const
{
if (!isSimulatorAvailable() || !getSimulatorStatus().testFlag(ISimulator::Simulating)) { return false; }
return true;
return isSimulatorAvailable() && getSimulatorStatus().testFlag(ISimulator::Simulating);
}
} // namespace swift::core::context

View File

@@ -26,8 +26,7 @@ namespace swift::core::fsd
ServerErrorCode::AuthTimeout,
};
if (fatalErrors.contains(m_errorNumber)) { return true; }
else { return false; }
return fatalErrors.contains(m_errorNumber);
}
QStringList ServerError::toTokens() const

View File

@@ -419,8 +419,7 @@ namespace swift::gui::components
bool CAtcStationComponent::canAccessContext() const
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return false; }
return true;
return sGui && !sGui->isShuttingDown() && sGui->getIContextNetwork();
}
void CAtcStationComponent::clearOnlineViews()

View File

@@ -48,11 +48,7 @@ namespace swift::gui
if (!this->isVisible()) { return false; }
// further checks
if (this->isFloating())
{
if (this->isMinimized()) { return false; }
return true;
}
if (this->isFloating()) { return !this->isMinimized(); }
else { return isSelectedDockWidget(); }
}

View File

@@ -543,7 +543,7 @@ namespace swift::gui
{
if (!sGui || sGui->isShuttingDown()) { return; }
this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East);
const bool init = m_tabBar ? false : true;
const bool init = m_tabBar == nullptr;
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
{

View File

@@ -40,7 +40,7 @@ namespace swift::gui
void CManagedStatusBar::initStatusBar(QStatusBar *statusBar)
{
if (m_statusBar) { return; }
m_ownedStatusBar = statusBar ? false : true;
m_ownedStatusBar = statusBar == nullptr;
m_statusBar = statusBar ? statusBar : new QStatusBar();
if (m_statusBar->objectName().isEmpty()) { m_statusBar->setObjectName("sb_ManagedStatusBar"); }

View File

@@ -14,8 +14,8 @@ namespace swift::gui::models
: m_id(id), m_vDesignator(vDesignator.trimmed().toUpper()), m_name(name.trimmed()),
m_countryIso(countryIso.trimmed().toUpper()), m_real(isReal), m_va(isVa)
{
this->m_valid = !(m_id < 0 && this->m_countryIso.isEmpty() && this->m_vDesignator.isEmpty() &&
this->m_name.isEmpty() && !this->m_va && !this->m_real);
this->m_valid = m_id >= 0 || !this->m_countryIso.isEmpty() || !this->m_vDesignator.isEmpty() ||
!this->m_name.isEmpty() || this->m_va || this->m_real;
}
CAirlineIcaoCodeList CAirlineIcaoFilter::filter(const CAirlineIcaoCodeList &inContainer) const

View File

@@ -112,7 +112,7 @@ namespace swift::gui::models
bool CListModelBase<T, UseCompare>::setData(const QModelIndex &index, const QVariant &value, int role)
{
auto dataRole = static_cast<Qt::ItemDataRole>(role);
if (!(dataRole == Qt::UserRole || dataRole == Qt::EditRole)) { return false; }
if (dataRole != Qt::UserRole && dataRole != Qt::EditRole) { return false; }
// check / init
if (!this->isValidIndex(index)) { return false; }

View File

@@ -94,7 +94,7 @@ namespace swift::gui::models
bool CListModelBaseNonTemplate::hasValidSortColumn() const
{
if (!(m_sortColumn >= 0 && m_sortColumn < m_columns.size())) { return false; }
if (m_sortColumn < 0 || m_sortColumn >= m_columns.size()) { return false; }
return m_columns.isSortable(m_sortColumn);
}

View File

@@ -24,7 +24,7 @@ namespace swift::gui::models
CStatusMessageList outContainer;
for (const CStatusMessage &msg : inContainer)
{
if (!(m_severity == CStatusMessage::SeverityInfo || m_severity == CStatusMessage::SeverityDebug))
if (m_severity != CStatusMessage::SeverityInfo && m_severity != CStatusMessage::SeverityDebug)
{
if (!msg.isSeverityHigherOrEqual(this->m_severity)) { continue; }
}

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();

View File

@@ -371,8 +371,8 @@ void CSwiftLauncher::setDefaults()
ui->rb_WindowNormal->setChecked(!setup.useFramelessWindow());
const CLauncherSetup::CoreMode mode = setup.getCoreMode();
ui->rb_SwiftStandalone->setChecked(mode == CLauncherSetup::Standalone ? true : false);
ui->rb_SwiftDistributed->setChecked(mode == CLauncherSetup::Distributed ? true : false);
ui->rb_SwiftStandalone->setChecked(mode == CLauncherSetup::Standalone);
ui->rb_SwiftDistributed->setChecked(mode == CLauncherSetup::Distributed);
const CLauncherSetup::AudioMode audio = setup.getAudioMode();
ui->cb_DisableCoreAudio->setChecked(audio.testFlag(CLauncherSetup::AudioDisableDistributedCoreAudio));