mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 16:55:36 +08:00
refactor: Fix readability-simplify-boolean-expr
This commit is contained in:
@@ -47,6 +47,7 @@ Checks: >
|
|||||||
readability-redundant-member-init,
|
readability-redundant-member-init,
|
||||||
cppcoreguidelines-init-variables,
|
cppcoreguidelines-init-variables,
|
||||||
readability-static-accessed-through-instance,
|
readability-static-accessed-through-instance,
|
||||||
|
readability-simplify-boolean-expr,
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: readability-identifier-naming.ClassCase
|
- key: readability-identifier-naming.ClassCase
|
||||||
|
|||||||
@@ -405,9 +405,7 @@ namespace swift::core
|
|||||||
if (CBuildConfig::isLocalDeveloperDebugBuild()) { return true; }
|
if (CBuildConfig::isLocalDeveloperDebugBuild()) { return true; }
|
||||||
|
|
||||||
const CDistribution d(this->getOwnDistribution());
|
const CDistribution d(this->getOwnDistribution());
|
||||||
if (d.isRestricted() && this->isSet(m_cmdDevelopment)) { return true; }
|
return d.isRestricted() && this->isSet(m_cmdDevelopment);
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessage CApplication::initLocalSettings()
|
CStatusMessage CApplication::initLocalSettings()
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ namespace swift::core::context
|
|||||||
|
|
||||||
bool IContextSimulator::isSimulatorSimulating() const
|
bool IContextSimulator::isSimulatorSimulating() const
|
||||||
{
|
{
|
||||||
if (!isSimulatorAvailable() || !getSimulatorStatus().testFlag(ISimulator::Simulating)) { return false; }
|
return isSimulatorAvailable() && getSimulatorStatus().testFlag(ISimulator::Simulating);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} // namespace swift::core::context
|
} // namespace swift::core::context
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ namespace swift::core::fsd
|
|||||||
ServerErrorCode::AuthTimeout,
|
ServerErrorCode::AuthTimeout,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fatalErrors.contains(m_errorNumber)) { return true; }
|
return fatalErrors.contains(m_errorNumber);
|
||||||
else { return false; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ServerError::toTokens() const
|
QStringList ServerError::toTokens() const
|
||||||
|
|||||||
@@ -419,8 +419,7 @@ namespace swift::gui::components
|
|||||||
|
|
||||||
bool CAtcStationComponent::canAccessContext() const
|
bool CAtcStationComponent::canAccessContext() const
|
||||||
{
|
{
|
||||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return false; }
|
return sGui && !sGui->isShuttingDown() && sGui->getIContextNetwork();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAtcStationComponent::clearOnlineViews()
|
void CAtcStationComponent::clearOnlineViews()
|
||||||
|
|||||||
@@ -48,11 +48,7 @@ namespace swift::gui
|
|||||||
if (!this->isVisible()) { return false; }
|
if (!this->isVisible()) { return false; }
|
||||||
|
|
||||||
// further checks
|
// further checks
|
||||||
if (this->isFloating())
|
if (this->isFloating()) { return !this->isMinimized(); }
|
||||||
{
|
|
||||||
if (this->isMinimized()) { return false; }
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else { return isSelectedDockWidget(); }
|
else { return isSelectedDockWidget(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -543,7 +543,7 @@ namespace swift::gui
|
|||||||
{
|
{
|
||||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East);
|
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++)
|
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace swift::gui
|
|||||||
void CManagedStatusBar::initStatusBar(QStatusBar *statusBar)
|
void CManagedStatusBar::initStatusBar(QStatusBar *statusBar)
|
||||||
{
|
{
|
||||||
if (m_statusBar) { return; }
|
if (m_statusBar) { return; }
|
||||||
m_ownedStatusBar = statusBar ? false : true;
|
m_ownedStatusBar = statusBar == nullptr;
|
||||||
m_statusBar = statusBar ? statusBar : new QStatusBar();
|
m_statusBar = statusBar ? statusBar : new QStatusBar();
|
||||||
if (m_statusBar->objectName().isEmpty()) { m_statusBar->setObjectName("sb_ManagedStatusBar"); }
|
if (m_statusBar->objectName().isEmpty()) { m_statusBar->setObjectName("sb_ManagedStatusBar"); }
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace swift::gui::models
|
|||||||
: m_id(id), m_vDesignator(vDesignator.trimmed().toUpper()), m_name(name.trimmed()),
|
: m_id(id), m_vDesignator(vDesignator.trimmed().toUpper()), m_name(name.trimmed()),
|
||||||
m_countryIso(countryIso.trimmed().toUpper()), m_real(isReal), m_va(isVa)
|
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_valid = m_id >= 0 || !this->m_countryIso.isEmpty() || !this->m_vDesignator.isEmpty() ||
|
||||||
this->m_name.isEmpty() && !this->m_va && !this->m_real);
|
!this->m_name.isEmpty() || this->m_va || this->m_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAirlineIcaoCodeList CAirlineIcaoFilter::filter(const CAirlineIcaoCodeList &inContainer) const
|
CAirlineIcaoCodeList CAirlineIcaoFilter::filter(const CAirlineIcaoCodeList &inContainer) const
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace swift::gui::models
|
|||||||
bool CListModelBase<T, UseCompare>::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool CListModelBase<T, UseCompare>::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
auto dataRole = static_cast<Qt::ItemDataRole>(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
|
// check / init
|
||||||
if (!this->isValidIndex(index)) { return false; }
|
if (!this->isValidIndex(index)) { return false; }
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace swift::gui::models
|
|||||||
|
|
||||||
bool CListModelBaseNonTemplate::hasValidSortColumn() const
|
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);
|
return m_columns.isSortable(m_sortColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace swift::gui::models
|
|||||||
CStatusMessageList outContainer;
|
CStatusMessageList outContainer;
|
||||||
for (const CStatusMessage &msg : inContainer)
|
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; }
|
if (!msg.isSeverityHigherOrEqual(this->m_severity)) { continue; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,8 +280,7 @@ namespace swift::misc::aviation
|
|||||||
// allow 2 chars for special codes like "VV"
|
// allow 2 chars for special codes like "VV"
|
||||||
if (airline.length() < 2 || airline.length() > 5) { return false; }
|
if (airline.length() < 2 || airline.length() > 5) { return false; }
|
||||||
const auto chars = makeRange(airline.begin(), airline.end());
|
const auto chars = makeRange(airline.begin(), airline.end());
|
||||||
if (chars.containsBy([](QChar c) { return !c.isUpper() && !c.isDigit(); })) { return false; }
|
return !chars.containsBy([](QChar c) { return !c.isUpper() && !c.isDigit(); });
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAirlineIcaoCode::isValidIataCode(const QString &iataCode)
|
bool CAirlineIcaoCode::isValidIataCode(const QString &iataCode)
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ namespace swift::misc::aviation
|
|||||||
if (msgs) { msgs->push_back(CStatusMessage(this).validationError(u"Altitude NULL value")); }
|
if (msgs) { msgs->push_back(CStatusMessage(this).validationError(u"Altitude NULL value")); }
|
||||||
return false;
|
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")); }
|
if (msgs) { msgs->push_back(CStatusMessage(this).validationError(u"Altitude, must be FL or MSL")); }
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -265,8 +265,7 @@ namespace swift::misc::network
|
|||||||
bool CNetworkUtils::looksLikePhpErrorMessage(const QString &errorMessage)
|
bool CNetworkUtils::looksLikePhpErrorMessage(const QString &errorMessage)
|
||||||
{
|
{
|
||||||
if (errorMessage.length() < 50) { return false; }
|
if (errorMessage.length() < 50) { return false; }
|
||||||
if (errorMessage.contains("xdebug", Qt::CaseInsensitive)) { return true; }
|
return errorMessage.contains("xdebug", Qt::CaseInsensitive);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CNetworkUtils::networkOperationToString(QNetworkAccessManager::Operation operation)
|
const QString &CNetworkUtils::networkOperationToString(QNetworkAccessManager::Operation operation)
|
||||||
|
|||||||
@@ -113,13 +113,11 @@ namespace swift::misc::network
|
|||||||
if (this->getSenderCallsign() != textMessage.getSenderCallsign()) { return false; }
|
if (this->getSenderCallsign() != textMessage.getSenderCallsign()) { return false; }
|
||||||
if (this->isRadioMessage() && textMessage.isRadioMessage())
|
if (this->isRadioMessage() && textMessage.isRadioMessage())
|
||||||
{
|
{
|
||||||
if (this->getFrequency() != textMessage.getFrequency()) { return false; }
|
return this->getFrequency() == textMessage.getFrequency();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (this->isPrivateMessage() && textMessage.isPrivateMessage())
|
else if (this->isPrivateMessage() && textMessage.isPrivateMessage())
|
||||||
{
|
{
|
||||||
if (this->getRecipientCallsign() != textMessage.getRecipientCallsign()) { return false; }
|
return this->getRecipientCallsign() == textMessage.getRecipientCallsign();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ namespace swift::misc::simulation::fscommon
|
|||||||
quint32 remainder = 0, quotient = 0, result = 0;
|
quint32 remainder = 0, quotient = 0, result = 0;
|
||||||
remainder = num % divider;
|
remainder = num % divider;
|
||||||
quotient = num / divider;
|
quotient = num / divider;
|
||||||
if (!(quotient == 0 && remainder == 0))
|
if (quotient != 0 || remainder != 0) { result += hornerScheme(quotient, divider, factor) * factor + remainder; }
|
||||||
{
|
|
||||||
result += hornerScheme(quotient, divider, factor) * factor + remainder;
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} // namespace swift::misc::simulation::fscommon
|
} // namespace swift::misc::simulation::fscommon
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ namespace swift::misc
|
|||||||
auto object = json.object();
|
auto object = json.object();
|
||||||
json.setObject(it->mergeToMemoizedJson(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")
|
return CStatusMessage(this).error(u"Failed to write to %1: %2")
|
||||||
<< file.fileName() << file.errorString();
|
<< file.fileName() << file.errorString();
|
||||||
|
|||||||
@@ -371,8 +371,8 @@ void CSwiftLauncher::setDefaults()
|
|||||||
ui->rb_WindowNormal->setChecked(!setup.useFramelessWindow());
|
ui->rb_WindowNormal->setChecked(!setup.useFramelessWindow());
|
||||||
|
|
||||||
const CLauncherSetup::CoreMode mode = setup.getCoreMode();
|
const CLauncherSetup::CoreMode mode = setup.getCoreMode();
|
||||||
ui->rb_SwiftStandalone->setChecked(mode == CLauncherSetup::Standalone ? true : false);
|
ui->rb_SwiftStandalone->setChecked(mode == CLauncherSetup::Standalone);
|
||||||
ui->rb_SwiftDistributed->setChecked(mode == CLauncherSetup::Distributed ? true : false);
|
ui->rb_SwiftDistributed->setChecked(mode == CLauncherSetup::Distributed);
|
||||||
|
|
||||||
const CLauncherSetup::AudioMode audio = setup.getAudioMode();
|
const CLauncherSetup::AudioMode audio = setup.getAudioMode();
|
||||||
ui->cb_DisableCoreAudio->setChecked(audio.testFlag(CLauncherSetup::AudioDisableDistributedCoreAudio));
|
ui->cb_DisableCoreAudio->setChecked(audio.testFlag(CLauncherSetup::AudioDisableDistributedCoreAudio));
|
||||||
|
|||||||
Reference in New Issue
Block a user