refactor: Fix clang-tidy warnings

This commit is contained in:
Lars Toenning
2024-12-01 11:04:25 +01:00
parent 7bc99ff6f2
commit a43b5ddc2b
38 changed files with 184 additions and 207 deletions

View File

@@ -12,15 +12,13 @@ SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::weather, CCloudLayer)
namespace swift::misc::weather
{
CCloudLayer::CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
Coverage coverage)
: m_base(base), m_top(top)
CCloudLayer::CCloudLayer(const CAltitude &base, const CAltitude &top, Coverage coverage) : m_base(base), m_top(top)
{
setCoverage(coverage);
}
CCloudLayer::CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
double precipitationRate, Precipitation precipitation, Clouds clouds, Coverage coverage)
CCloudLayer::CCloudLayer(const CAltitude &base, const CAltitude &top, double precipitationRate,
Precipitation precipitation, Clouds clouds, Coverage coverage)
: m_base(base), m_top(top), m_precipitationRate(precipitationRate), m_precipitation(precipitation),
m_clouds(clouds)
{
@@ -38,11 +36,10 @@ namespace swift::misc::weather
return None;
}
QVariant CCloudLayer::propertyByIndex(swift::misc::CPropertyIndexRef index) const
QVariant CCloudLayer::propertyByIndex(CPropertyIndexRef index) const
{
if (index.isMyself()) { return QVariant::fromValue(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
switch (index.frontCasted<ColumnIndex>())
{
case IndexBase: return QVariant::fromValue(m_base);
case IndexTop: return QVariant::fromValue(m_top);
@@ -61,8 +58,7 @@ namespace swift::misc::weather
(*this) = variant.value<CCloudLayer>();
return;
}
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
switch (index.frontCasted<ColumnIndex>())
{
case IndexBase: setBase(variant.value<CAltitude>()); break;
case IndexTop: setTop(variant.value<CAltitude>()); break;

View File

@@ -72,24 +72,23 @@ namespace swift::misc::weather
CCloudLayer() = default;
//! Constructor
CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
Coverage coverage);
CCloudLayer(const misc::aviation::CAltitude &base, const misc::aviation::CAltitude &top, Coverage coverage);
//! Constructor
CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
CCloudLayer(const misc::aviation::CAltitude &base, const misc::aviation::CAltitude &top,
double precipitationRate, Precipitation precipitation, Clouds clouds, Coverage coverage);
//! Set base
void setBase(const swift::misc::aviation::CAltitude &base) { m_base = base; }
void setBase(const misc::aviation::CAltitude &base) { m_base = base; }
//! Get base
swift::misc::aviation::CAltitude getBase() const { return m_base; }
misc::aviation::CAltitude getBase() const { return m_base; }
//! Set layer top
void setTop(const swift::misc::aviation::CAltitude &top) { m_top = top; }
void setTop(const misc::aviation::CAltitude &top) { m_top = top; }
//! Get layer top
swift::misc::aviation::CAltitude getTop() const { return m_top; }
misc::aviation::CAltitude getTop() const { return m_top; }
//! Set precipitation rate in mm/h
void setPrecipitationRate(double rate) { m_precipitationRate = rate; }
@@ -131,12 +130,12 @@ namespace swift::misc::weather
QString convertToQString(bool i18n = false) const;
private:
swift::misc::aviation::CAltitude m_base;
swift::misc::aviation::CAltitude m_top;
aviation::CAltitude m_base;
aviation::CAltitude m_top;
double m_precipitationRate = 0; //!< Unit mm/h
Precipitation m_precipitation = NoPrecipitation;
Clouds m_clouds = NoClouds;
int m_coveragePercent;
int m_coveragePercent {};
SWIFT_METACLASS(
CCloudLayer,

View File

@@ -39,10 +39,10 @@ namespace swift::misc
CCloudLayerList(const CSequence<CCloudLayer> &other);
//! Contains cloud layer with base?
bool containsBase(const swift::misc::aviation::CAltitude &base) const;
bool containsBase(const aviation::CAltitude &base) const;
//! Find cloud layer by base
CCloudLayer findByBase(const swift::misc::aviation::CAltitude &base) const;
CCloudLayer findByBase(const aviation::CAltitude &base) const;
};
} // namespace weather

View File

@@ -42,7 +42,7 @@ namespace swift::misc::weather
{
public:
//! Destructor
virtual ~IMetarDecoderPart() {}
virtual ~IMetarDecoderPart() = default;
//! Decoder type ("name")
virtual QString getDecoderType() const = 0;
@@ -98,7 +98,7 @@ namespace swift::misc::weather
class CMetarDecoderReportType : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "ReportType"; }
QString getDecoderType() const override { return "ReportType"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -116,7 +116,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
const QHash<QString, CMetar::ReportType> &getReportTypeHash() const
@@ -130,7 +130,7 @@ namespace swift::misc::weather
class CMetarDecoderAirport : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Airport"; }
QString getDecoderType() const override { return "Airport"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -147,13 +147,13 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return true; }
bool isMandatory() const override { return true; }
};
class CMetarDecoderDayTime : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "DayTime"; }
QString getDecoderType() const override { return "DayTime"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -179,13 +179,13 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return true; }
bool isMandatory() const override { return true; }
};
class CMetarDecoderStatus : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Status"; }
QString getDecoderType() const override { return "Status"; }
protected:
// Possible matches:
@@ -210,13 +210,13 @@ namespace swift::misc::weather
else { return false; }
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
};
class CMetarDecoderWind : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Wind"; }
QString getDecoderType() const override { return "Wind"; }
protected:
const QHash<QString, CSpeedUnit> &getWindUnitHash() const
@@ -271,7 +271,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -293,7 +293,7 @@ namespace swift::misc::weather
class CMetarDecoderVariationsWindDirection : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "WindDirection"; }
QString getDecoderType() const override { return "WindDirection"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -321,7 +321,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -339,7 +339,7 @@ namespace swift::misc::weather
class CMetarDecoderVisibility : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Visibility"; }
QString getDecoderType() const override { return "Visibility"; }
protected:
const QHash<QString, QString> &getCardinalDirections() const
@@ -406,7 +406,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -436,7 +436,7 @@ namespace swift::misc::weather
class CMetarDecoderRunwayVisualRange : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "RunwayVisualRange"; }
QString getDecoderType() const override { return "RunwayVisualRange"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -464,7 +464,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -493,7 +493,7 @@ namespace swift::misc::weather
class CMetarDecoderPresentWeather : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "PresentWeather"; }
QString getDecoderType() const override { return "PresentWeather"; }
protected:
const QHash<QString, CPresentWeather::Intensity> &getIntensityHash() const
@@ -545,7 +545,7 @@ namespace swift::misc::weather
return hash;
}
virtual bool isRepeatable() const override { return true; }
bool isRepeatable() const override { return true; }
const QRegularExpression &getRegExp() const override
{
@@ -575,7 +575,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -604,7 +604,7 @@ namespace swift::misc::weather
class CMetarDecoderCloud : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Cloud"; }
QString getDecoderType() const override { return "Cloud"; }
protected:
const QStringList &getClearSkyTokens() const
@@ -623,7 +623,7 @@ namespace swift::misc::weather
return hash;
}
virtual bool isRepeatable() const override { return true; }
bool isRepeatable() const override { return true; }
const QRegularExpression &getRegExp() const override
{
@@ -660,7 +660,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -683,7 +683,7 @@ namespace swift::misc::weather
class CMetarDecoderVerticalVisibility : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "VerticalVisibility"; }
QString getDecoderType() const override { return "VerticalVisibility"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -698,7 +698,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -713,7 +713,7 @@ namespace swift::misc::weather
class CMetarDecoderTemperature : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Temperature"; }
QString getDecoderType() const override { return "Temperature"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -756,7 +756,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -776,7 +776,7 @@ namespace swift::misc::weather
class CMetarDecoderPressure : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "Pressure"; }
QString getDecoderType() const override { return "Pressure"; }
protected:
const QHash<QString, CPressureUnit> &getPressureUnits() const
@@ -822,7 +822,7 @@ namespace swift::misc::weather
return false;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -842,7 +842,7 @@ namespace swift::misc::weather
class CMetarDecoderRecentWeather : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "RecentWeather"; }
QString getDecoderType() const override { return "RecentWeather"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -857,7 +857,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -884,7 +884,7 @@ namespace swift::misc::weather
class CMetarDecoderWindShear : public IMetarDecoderPart
{
public:
virtual QString getDecoderType() const override { return "WindShear"; }
QString getDecoderType() const override { return "WindShear"; }
protected:
const QRegularExpression &getRegExp() const override
@@ -906,7 +906,7 @@ namespace swift::misc::weather
return true;
}
virtual bool isMandatory() const override { return false; }
bool isMandatory() const override { return false; }
private:
QString getRegExpImpl() const
@@ -935,7 +935,7 @@ namespace swift::misc::weather
{
const QString type = decoder->getDecoderType();
CLogMessage(this).debug() << "Invalid METAR:" << metarString << type;
return CMetar();
return {};
}
}

View File

@@ -29,7 +29,7 @@ namespace swift::misc::weather
CMetarDecoder();
//! Default destructor
virtual ~CMetarDecoder() override;
~CMetarDecoder() override;
//! Decode metar
CMetar decode(const QString &metarString) const;