Commit fbe40764 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some clazy warning

parent 1b49ddef
......@@ -33,14 +33,14 @@ private Q_SLOTS:
req.setCoordinate(52.5, 13.5);
QVERIFY(!req.cacheKey().isEmpty());
auto entry = Cache::lookupLocation(QLatin1String("unittest"), req.cacheKey());
auto entry = Cache::lookupLocation(QStringLiteral("unittest"), req.cacheKey());
QCOMPARE(entry.type, CacheHitType::Miss);
Cache::addNegativeLocationCacheEntry(QStringLiteral("unittest"), req.cacheKey());
entry = Cache::lookupLocation(QLatin1String("unittest"), req.cacheKey());
entry = Cache::lookupLocation(QStringLiteral("unittest"), req.cacheKey());
QCOMPARE(entry.type, CacheHitType::Negative);
Cache::expire();
entry = Cache::lookupLocation(QLatin1String("unittest"), req.cacheKey());
entry = Cache::lookupLocation(QStringLiteral("unittest"), req.cacheKey());
QCOMPARE(entry.type, CacheHitType::Negative);
Location loc;
......
......@@ -58,7 +58,7 @@ private Q_SLOTS:
QCOMPARE(sec.notes(), res);
Stopover dep;
for (const auto &note : in)
for (const auto &note : qAsConst(in))
dep.addNote(note);
QCOMPARE(dep.notes(), res);
}
......
......@@ -123,7 +123,7 @@ void LineInfo::merge(LineInfo &lhs, const LineInfo &rhs)
}
}
QDebug operator<<(QDebug debug, LineInfo info)
QDebug operator<<(QDebug debug, const LineInfo &info)
{
QDebugStateSaver saver(debug);
debug.noquote().nospace()
......
......@@ -47,6 +47,6 @@ public:
std::vector<Wikidata::Q> wdProducts;
};
QDebug operator<<(QDebug debug, LineInfo info);
QDebug operator<<(QDebug debug, const LineInfo &info);
#endif // LINEINFO_H
......@@ -37,7 +37,7 @@ static void parseCompactIfopt(ScopedXmlStreamReader &reader, Location &loc)
}
} else if (reader.name() == QLatin1String("gid")) {
const auto id = reader.readElementText();
if (IfoptUtil::isValid(id) && loc.identifier(QLatin1String("ifopt")).isEmpty()) {
if (IfoptUtil::isValid(id) && loc.identifier(QStringLiteral("ifopt")).isEmpty()) {
loc.setIdentifier(QStringLiteral("ifopt"), id);
}
}
......
......@@ -484,7 +484,7 @@ static std::vector<Path> parsePaths(const QJsonArray &polyL, const std::vector<L
sections.reserve(ppLocRefL.size() - 1);
int prevPpIdx = 0;
QPointF prevCoord;
for (const auto ppLocRefV : ppLocRefL) {
for (const auto &ppLocRefV : ppLocRefL) {
const auto ppLocRef = ppLocRefV.toObject();
const auto ppIdx = ppLocRef.value(QLatin1String("ppIdx")).toInt();
if (ppIdx == 0 || ppIdx < prevPpIdx) {
......
......@@ -102,11 +102,11 @@ std::vector<Vehicle> HafasVehicleLayoutParser::parseVehicleLayouts(const QJsonOb
const auto stcGrpL = commonObj.value(QLatin1String("stcGrpL")).toArray();
std::vector<Vehicle> vehicles;
vehicles.reserve(stcGrpL.size());
for (const auto stcGrpV : stcGrpL) {
for (const auto &stcGrpV : stcGrpL) {
const auto carL = stcGrpV.toObject().value(QLatin1String("carL")).toArray();
std::vector<VehicleSection> sections;
sections.reserve(carL.size());
for (const auto carV : carL) {
for (const auto &carV : carL) {
const auto carIdx = carV.toInt();
if (carIdx >= 0 && carIdx < (int)cars.size()) {
sections.push_back(cars[carIdx]);
......
......@@ -106,7 +106,7 @@ static Location parseLocation(const QJsonObject &obj)
if (codes.empty()) {
codes = obj.value(QLatin1String("stop_area")).toObject().value(QLatin1String("codes")).toArray();
}
for (const auto &codeV : codes) {
for (const auto &codeV : qAsConst(codes)) {
const auto code = codeV.toObject();
if (code.value(QLatin1String("type")).toString() == QLatin1String("UIC8")) {
loc.setIdentifier(QStringLiteral("uic"), code.value(QLatin1String("value")).toString().left(7));
......
......@@ -67,7 +67,7 @@ bool Line::hasTextColor() const
return d->textColor.isValid();
}
void Line::setMetaData(LineMetaData metaData)
void Line::setMetaData(const LineMetaData &metaData)
{
d->metaData = metaData;
}
......
......@@ -111,7 +111,7 @@ public:
private:
friend void LineUtil::setMetaData(Line&, LineMetaData);
void setMetaData(LineMetaData metaData);
void setMetaData(const LineMetaData &metaData);
};
class RoutePrivate;
......
......@@ -272,8 +272,8 @@ bool Location::isSame(const Location &lhs, const Location &rhs)
}
// ids - IFOPT takes priority here due to its special hierarchical handling, but only for stations
const auto lhsIfopt = lhs.identifier(QLatin1String("ifopt"));
const auto rhsIfopt = rhs.identifier(QLatin1String("ifopt"));
const auto lhsIfopt = lhs.identifier(QStringLiteral("ifopt"));
const auto rhsIfopt = rhs.identifier(QStringLiteral("ifopt"));
if (!lhsIfopt.isEmpty() && !rhsIfopt.isEmpty() && (lhs.type() == Location::Stop || rhs.type() == Location::Stop)) {
return IfoptUtil::isSameStopPlace(lhsIfopt, rhsIfopt);
}
......@@ -374,7 +374,7 @@ Location Location::merge(const Location &lhs, const Location &rhs)
const auto rhsIds = rhs.identifiers();
for (auto it = rhsIds.constBegin(); it != rhsIds.constEnd(); ++it) {
if (it.key() == QLatin1String("ifopt")) {
l.setIdentifier(QStringLiteral("ifopt"), IfoptUtil::merge(l.identifier(QLatin1String("ifopt")), it.value()).toString());
l.setIdentifier(QStringLiteral("ifopt"), IfoptUtil::merge(l.identifier(QStringLiteral("ifopt")), it.value()).toString());
continue;
}
if (lhs.identifier(it.key()).isEmpty()) {
......
......@@ -70,7 +70,7 @@ static void appendResults(const GBFSService &service, const LocationRequest &req
const auto stations = stationsDoc.object().value(QLatin1String("data")).toObject().value(QLatin1String("stations")).toArray();
std::vector<QString> selectedStationIds;
for (const auto stationV : stations) {
for (const auto &stationV : stations) {
const auto station = stationV.toObject();
const auto lat = station.value(QLatin1String("lat")).toDouble();
const auto lon = station.value(QLatin1String("lon")).toDouble();
......@@ -96,7 +96,7 @@ static void appendResults(const GBFSService &service, const LocationRequest &req
const auto statusDoc = store.loadData(GBFS::StationStatus);
const auto status = statusDoc.object().value(QLatin1String("data")).toObject().value(QLatin1String("stations")).toArray();
for (const auto statV : status) {
for (const auto &statV : status) {
const auto stat = statV.toObject();
const auto id = stationIdToString(stat.value(QLatin1String("station_id")));
const auto it = std::find(selectedStationIds.begin(), selectedStationIds.end(), id);
......@@ -112,7 +112,7 @@ static void appendResults(const GBFSService &service, const LocationRequest &req
const auto floatingDoc = store.loadData(GBFS::FreeBikeStatus);
const auto floating = floatingDoc.object().value(QLatin1String("data")).toObject().value(QLatin1String("bikes")).toArray();
for (const auto bikeV : floating) {
for (const auto &bikeV : floating) {
const auto bike = bikeV.toObject();
if (bike.value(QLatin1String("is_reserved")).toBool() || bike.value(QLatin1String("is_disabled")).toBool()) {
continue;
......
......@@ -116,7 +116,7 @@ void GBFSJob::parseDiscoverData(bool sysInfoOnly)
return;
}
for (const auto &feedVal : feeds) {
for (const auto &feedVal : qAsConst(feeds)) {
const auto feed = feedVal.toObject();
const auto name = feed.value(QLatin1String("name")).toString();
const auto type = GBFS::typeForKeyName(name);
......
......@@ -46,7 +46,7 @@ int main(int argc, char **argv)
completer->setCompletionRole(Qt::DisplayRole);
lineEdit->setCompleter(completer);
// TODO compress queries with a short timer
QObject::connect(lineEdit, &QLineEdit::textEdited, model, [completer, model](const auto &text) {
QObject::connect(lineEdit, &QLineEdit::textEdited, model, [model](const auto &text) {
LocationRequest req;
req.setName(text);
model->setRequest(req);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment