From df856114eba1e178416b9883e54a3c6946a3385d 2018-08-14 18:12:07 From: Alexis Jeandet Date: 2018-08-14 18:12:07 Subject: [PATCH] Followed Clazy and Clang advises and disabled few old tests Signed-off-by: Alexis Jeandet --- diff --git a/include/Data/DateTimeRange.h b/include/Data/DateTimeRange.h index 7384724..23d8cd3 100644 --- a/include/Data/DateTimeRange.h +++ b/include/Data/DateTimeRange.h @@ -126,17 +126,17 @@ struct DateTimeRange { std::vector result; if(std::isnan(other.m_TStart)||std::isnan(other.m_TEnd)||!this->intersect(other)) { - result.push_back({m_TStart, m_TEnd}); + result.emplace_back(m_TStart, m_TEnd); } else { if(this->m_TStartm_TStart, other.m_TStart}); + result.emplace_back(this->m_TStart, other.m_TStart); } if(this->m_TEnd>other.m_TEnd) { - result.push_back({this->m_TEnd, other.m_TEnd}); + result.emplace_back(this->m_TEnd, other.m_TEnd); } } return result; diff --git a/include/Data/DateTimeRangeHelper.h b/include/Data/DateTimeRangeHelper.h index a6420d0..68780ba 100644 --- a/include/Data/DateTimeRangeHelper.h +++ b/include/Data/DateTimeRangeHelper.h @@ -16,23 +16,23 @@ namespace DateTimeRangeHelper { - bool isnan(const DateTimeRange& range) + inline bool isnan(const DateTimeRange& range) { return std::isnan(range.m_TStart) && std::isnan(range.m_TEnd); } - bool hasnan(const DateTimeRange& range) + inline bool hasnan(const DateTimeRange& range) { return std::isnan(range.m_TStart) || std::isnan(range.m_TEnd); } - bool isPureShift(const DateTimeRange& range1, const DateTimeRange& range2) + inline bool isPureShift(const DateTimeRange& range1, const DateTimeRange& range2) { return SciQLop::numeric::almost_equal(range1.delta(), range2.delta(), 1) && !SciQLop::numeric::almost_equal(range1.m_TStart, range2.m_TStart, 1); } - bool isPureZoom(const DateTimeRange& range1, const DateTimeRange& range2) + inline bool isPureZoom(const DateTimeRange& range1, const DateTimeRange& range2) { return !SciQLop::numeric::almost_equal(range1.delta(),range2.delta(),1)&& SciQLop::numeric::almost_equal(range1.center(), range2.center(),1); @@ -45,7 +45,7 @@ namespace DateTimeRangeHelper { * @return trnaformation applied to range1 to get range2 or an object of type * InvalidDateTimeRangeTransformation if the transformation has NaN or forbiden values */ - std::variant + inline std::variant computeTransformation(const DateTimeRange& range1, const DateTimeRange& range2) { double zoom = range2.delta()/range1.delta(); diff --git a/include/Variable/VariableController2.h b/include/Variable/VariableController2.h index 3ca6f10..2e5d848 100644 --- a/include/Variable/VariableController2.h +++ b/include/Variable/VariableController2.h @@ -22,18 +22,19 @@ class VariableController2: public QObject public: explicit VariableController2(); std::shared_ptr createVariable(const QString &name, const QVariantHash &metadata, - std::shared_ptr provider, const DateTimeRange &range); + const std::shared_ptr& provider, + const DateTimeRange &range); - void deleteVariable(std::shared_ptr variable); - void changeRange(std::shared_ptr variable, DateTimeRange r); - void asyncChangeRange(std::shared_ptr variable, DateTimeRange r); + void deleteVariable(const std::shared_ptr& variable); + void changeRange(const std::shared_ptr& variable, const DateTimeRange& r); + void asyncChangeRange(const std::shared_ptr& variable, const DateTimeRange& r); const std::set> variables(); - void synchronize(std::shared_ptr var, std::shared_ptr with); + void synchronize(const std::shared_ptr& var, const std::shared_ptr& with); signals: - void variableAdded(std::shared_ptr); - void variableDeleted(std::shared_ptr); + void variableAdded(const std::shared_ptr&); + void variableDeleted(const std::shared_ptr&); }; diff --git a/src/Variable/VariableController2.cpp b/src/Variable/VariableController2.cpp index 1aca265..730e2de 100644 --- a/src/Variable/VariableController2.cpp +++ b/src/Variable/VariableController2.cpp @@ -12,20 +12,20 @@ class VariableController2::VariableController2Private QMap> _providers; QMap> _synchronizationGroups; std::unique_ptr _cacheStrategy; - bool p_contains(std::shared_ptr variable) + bool p_contains(const std::shared_ptr& variable) { return _providers.contains(variable->ID()); } - bool v_contains(std::shared_ptr variable) + bool v_contains(const std::shared_ptr& variable) { return SciQLop::containers::contains(this->_variables, variable); } - bool sg_contains(std::shared_ptr variable) + bool sg_contains(const std::shared_ptr& variable) { return _synchronizationGroups.contains(variable->ID()); } - void _changeRange(std::shared_ptr var, DateTimeRange r) + void _changeRange(const std::shared_ptr& var, DateTimeRange r) { auto provider = _providers[var->ID()]; DateTimeRange newCacheRange; @@ -61,12 +61,12 @@ public: { auto newVar = std::make_shared(name,metadata); this->_variables[newVar->ID()] = newVar; - this->_providers[newVar->ID()] = provider; + this->_providers[newVar->ID()] = std::move(provider); this->_synchronizationGroups[newVar->ID()] = std::make_shared(newVar->ID()); return newVar; } - void deleteVariable(std::shared_ptr variable) + void deleteVariable(const std::shared_ptr& variable) { /* * Removing twice a var is ok but a var without provider has to be a hard error @@ -80,7 +80,7 @@ public: SCIQLOP_ERROR(VariableController2Private, "No provider found for given variable"); } - void changeRange(std::shared_ptr variable, DateTimeRange r) + void changeRange(const std::shared_ptr& variable, DateTimeRange r) { if(p_contains(variable)) { @@ -118,7 +118,7 @@ public: } } - void synchronize(std::shared_ptr var, std::shared_ptr with) + void synchronize(const std::shared_ptr& var, const std::shared_ptr& with) { if(v_contains(var) && v_contains(with)) { @@ -143,7 +143,7 @@ public: const std::set> variables() { std::set> vars; - for(auto var:_variables.values()) + for(const auto &var:_variables) { vars.insert(var); } @@ -156,7 +156,7 @@ VariableController2::VariableController2() :impl{spimpl::make_unique_impl()} {} -std::shared_ptr VariableController2::createVariable(const QString &name, const QVariantHash &metadata, std::shared_ptr provider, const DateTimeRange &range) +std::shared_ptr VariableController2::createVariable(const QString &name, const QVariantHash &metadata, const std::shared_ptr& provider, const DateTimeRange &range) { auto var = impl->createVariable(name, metadata, provider); emit variableAdded(var); @@ -167,13 +167,13 @@ std::shared_ptr VariableController2::createVariable(const QString &nam return var; } -void VariableController2::deleteVariable(std::shared_ptr variable) +void VariableController2::deleteVariable(const std::shared_ptr& variable) { impl->deleteVariable(variable); emit variableDeleted(variable); } -void VariableController2::changeRange(std::shared_ptr variable, DateTimeRange r) +void VariableController2::changeRange(const std::shared_ptr& variable, const DateTimeRange& r) { impl->changeRange(variable, r); } @@ -183,7 +183,7 @@ const std::set > VariableController2::variables() return impl->variables(); } -void VariableController2::synchronize(std::shared_ptr var, std::shared_ptr with) +void VariableController2::synchronize(const std::shared_ptr &var, const std::shared_ptr &with) { impl->synchronize(var, with); } diff --git a/tests/Variable/TestVariable.cpp b/tests/Variable/TestVariable.cpp index 5070ca4..b49299f 100644 --- a/tests/Variable/TestVariable.cpp +++ b/tests/Variable/TestVariable.cpp @@ -39,6 +39,7 @@ class TestVariable : public QObject { Q_OBJECT private slots: + void initTestCase() { QSKIP("Skip it"); } void testClone_data(); void testClone(); diff --git a/tests/Variable/TestVariableCacheController.cpp b/tests/Variable/TestVariableCacheController.cpp index fcfafe9..17ad019 100644 --- a/tests/Variable/TestVariableCacheController.cpp +++ b/tests/Variable/TestVariableCacheController.cpp @@ -10,6 +10,8 @@ class TestVariableCacheController : public QObject { Q_OBJECT private slots: + void initTestCase() { QSKIP("Skip it"); } + void testProvideNotInCacheDateTimeList(); void testAddDateTime(); diff --git a/tests/Variable/TestVariableController.cpp b/tests/Variable/TestVariableController.cpp index 6b2b0de..04f9351 100644 --- a/tests/Variable/TestVariableController.cpp +++ b/tests/Variable/TestVariableController.cpp @@ -44,6 +44,8 @@ class TestVariableController : public QObject { Q_OBJECT private slots: + void initTestCase() { QSKIP("Skip it"); } + /// Test removes variable from controller void testDeleteVariable(); };