mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Fix clang-tidy modernize-loop-convert
This commit is contained in:
@@ -6,6 +6,7 @@ Checks: >
|
||||
modernize-use-auto,
|
||||
modernize-use-override,
|
||||
modernize-return-braced-init-list,
|
||||
modernize-loop-convert,
|
||||
|
||||
|
||||
CheckOptions:
|
||||
|
||||
@@ -106,9 +106,8 @@ namespace swift::core::afv::audio
|
||||
{
|
||||
bool audioPlayed = false;
|
||||
QVector<quint16> handledTransceiverIDs;
|
||||
for (int i = 0; i < rxTransceiversFilteredAndSorted.size(); i++)
|
||||
for (const auto rxTransceiver : rxTransceiversFilteredAndSorted)
|
||||
{
|
||||
const RxTransceiverDto rxTransceiver = rxTransceiversFilteredAndSorted[i];
|
||||
if (!handledTransceiverIDs.contains(rxTransceiver.id))
|
||||
{
|
||||
handledTransceiverIDs.push_back(rxTransceiver.id);
|
||||
|
||||
@@ -48,11 +48,11 @@ namespace swift::core::afv::model
|
||||
QVector<CSampleAtcStation> transceivers;
|
||||
QString callsign;
|
||||
|
||||
for (auto it = rootArray.begin(); it != rootArray.end(); ++it)
|
||||
for (auto it : rootArray)
|
||||
{
|
||||
if (it->isObject())
|
||||
if (it.isObject())
|
||||
{
|
||||
const QJsonObject stationObject = it->toObject();
|
||||
const QJsonObject stationObject = it.toObject();
|
||||
|
||||
if (stationObject.contains("callsign")) { callsign = stationObject.value("callsign").toString(); }
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace swift::core::afv::model
|
||||
if (stationObject.contains("transceivers"))
|
||||
{
|
||||
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
||||
for (auto &&jt : txArray)
|
||||
{
|
||||
const TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
const TransceiverDto transceiver = TransceiverDto::fromJson(jt.toObject());
|
||||
transceivers.push_back({ callsign, transceiver });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace swift::misc::aviation
|
||||
CAircraftEngineList::CAircraftEngineList(std::initializer_list<bool> enginesOnOff)
|
||||
{
|
||||
int no = 1; // engines 1 based
|
||||
for (auto it = enginesOnOff.begin(); it != enginesOnOff.end(); ++it)
|
||||
for (bool it : enginesOnOff)
|
||||
{
|
||||
CAircraftEngine engine(no++, *it);
|
||||
CAircraftEngine engine(no++, it);
|
||||
this->push_back(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,11 +136,10 @@ namespace swift::misc
|
||||
if (value.isUndefined()) { throw CJsonException("Missing 'containerbase'"); }
|
||||
QJsonArray array = value.toArray();
|
||||
int index = 0;
|
||||
for (auto i = array.begin(); i != array.end(); ++i)
|
||||
for (auto ref : array)
|
||||
{
|
||||
CJsonScope scope("containerbase", index++);
|
||||
Q_UNUSED(scope);
|
||||
QJsonValueRef ref = (*i);
|
||||
typename Derived::value_type val;
|
||||
ref >> val;
|
||||
derived().push_back(std::move(val));
|
||||
|
||||
@@ -763,14 +763,14 @@ namespace swift::misc
|
||||
QJsonArray CDataCacheRevision::toJson(const QSet<QString> &pins)
|
||||
{
|
||||
QJsonArray result;
|
||||
for (auto it = pins.begin(); it != pins.end(); ++it) { result.push_back(*it); }
|
||||
for (const auto &pin : pins) { result.push_back(pin); }
|
||||
return result;
|
||||
}
|
||||
|
||||
QSet<QString> CDataCacheRevision::fromJson(const QJsonArray &pins)
|
||||
{
|
||||
QSet<QString> result;
|
||||
for (auto it = pins.begin(); it != pins.end(); ++it) { result.insert(it->toString()); }
|
||||
for (auto pin : pins) { result.insert(pin.toString()); }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -639,10 +639,10 @@ namespace swift::misc::json
|
||||
{
|
||||
QStringList sl;
|
||||
if (array.isEmpty()) { return sl; }
|
||||
for (int i = 0; i < array.size(); i++)
|
||||
for (const auto &i : array)
|
||||
{
|
||||
if (!array.at(i).isString()) { continue; }
|
||||
sl.push_back(array.at(i).toString());
|
||||
if (!i.isString()) { continue; }
|
||||
sl.push_back(i.toString());
|
||||
}
|
||||
return sl;
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,7 @@ namespace swift::misc::simulation
|
||||
{
|
||||
CAircraftModel::MemoHelper::CMemoizer helper;
|
||||
QJsonArray array;
|
||||
for (auto it = cbegin(); it != cend(); ++it) { array << it->toMemoizedJson(helper); }
|
||||
for (const auto &it : *this) { array << it.toMemoizedJson(helper); }
|
||||
QJsonObject json;
|
||||
json.insert("containerbase", array);
|
||||
json.insert("aircraftIcaos", helper.getTable<CAircraftIcaoCode>().toJson());
|
||||
@@ -1563,12 +1563,12 @@ namespace swift::misc::simulation
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (auto i = array.begin(); i != array.end(); ++i)
|
||||
for (auto &&i : array)
|
||||
{
|
||||
CJsonScope scope("containerbase", index++);
|
||||
Q_UNUSED(scope)
|
||||
CAircraftModel value;
|
||||
value.convertFromMemoizedJson(i->toObject(), helper);
|
||||
value.convertFromMemoizedJson(i.toObject(), helper);
|
||||
this->push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,20 +295,14 @@ namespace swift::misc::simulation
|
||||
|
||||
bool CInterpolatorSpline::areAnyElevationsMissing() const
|
||||
{
|
||||
for (unsigned int i = 0; i < m_s.size(); i++)
|
||||
{
|
||||
if (!m_s[i].hasGroundElevation()) { return true; }
|
||||
}
|
||||
return false;
|
||||
return std::any_of(m_s.begin(), m_s.end(),
|
||||
[](const auto &situation) { return !situation.hasGroundElevation(); });
|
||||
}
|
||||
|
||||
bool CInterpolatorSpline::isAnySituationNearGroundRelevant() const
|
||||
{
|
||||
for (unsigned int i = 0; i < m_s.size(); i++)
|
||||
{
|
||||
if (!m_s[i].canLikelySkipNearGroundInterpolation()) { return true; }
|
||||
}
|
||||
return false;
|
||||
return std::any_of(m_s.begin(), m_s.end(),
|
||||
[](const auto &situation) { return !situation.canLikelySkipNearGroundInterpolation(); });
|
||||
}
|
||||
|
||||
CInterpolatorSpline::CInterpolant::CInterpolant(const CInterpolatorSpline::PosArray &pa,
|
||||
|
||||
@@ -226,9 +226,8 @@ namespace swift::misc
|
||||
"i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "y" });
|
||||
|
||||
QString output = "";
|
||||
for (int i = 0; i < candidate.length(); i++)
|
||||
for (const QChar c : candidate)
|
||||
{
|
||||
const QChar c = candidate[i];
|
||||
const qsizetype dIndex = diacriticLetters.indexOf(c);
|
||||
if (dIndex < 0) { output.append(c); }
|
||||
else
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace swift::sound::sample_provider
|
||||
|
||||
for (int n = 0; n < samplesRead; n++)
|
||||
{
|
||||
for (int band = 0; band < m_filters.size(); band++) { samples[n] = m_filters[band].transform(samples[n]); }
|
||||
for (auto &filter : m_filters) { samples[n] = filter.transform(samples[n]); }
|
||||
samples[n] *= static_cast<float>(m_outputGain);
|
||||
}
|
||||
return samplesRead;
|
||||
|
||||
@@ -31,9 +31,8 @@ namespace swift::sound::sample_provider
|
||||
int outputLen = 0;
|
||||
|
||||
QVector<ISampleProvider *> finishedProviders;
|
||||
for (int i = 0; i < m_sources.size(); i++)
|
||||
for (auto sampleProvider : m_sources)
|
||||
{
|
||||
ISampleProvider *sampleProvider = m_sources.at(i);
|
||||
QVector<float> sourceBuffer;
|
||||
|
||||
const int len = sampleProvider->readSamples(sourceBuffer, count);
|
||||
|
||||
Reference in New Issue
Block a user