From 448720848b383639c37f5f0487efdf8c0f0ed433 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 28 Mar 2020 17:55:41 +0000 Subject: Fixes for tidy --- libpqpp/pq-command.h | 6 +++--- libpqpp/pq-connection.h | 13 ++++++++----- libpqpp/pq-error.h | 2 +- libpqpp/pq-mock.h | 10 ++++++---- libpqpp/unittests/testpq.cpp | 8 +++++--- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/libpqpp/pq-command.h b/libpqpp/pq-command.h index 4123d4c..101afd8 100644 --- a/libpqpp/pq-command.h +++ b/libpqpp/pq-command.h @@ -14,7 +14,7 @@ namespace PQ { class DLL_PUBLIC CommandOptions : public DB::CommandOptions { public: CommandOptions(std::size_t, const DB::CommandOptionsMap &); - CommandOptions(std::size_t hash, + explicit CommandOptions(std::size_t hash, unsigned int fetchTuples = 35, bool useCursor = true, bool fetchBinary = false); @@ -23,8 +23,8 @@ namespace PQ { bool useCursor; bool fetchBinary; }; - typedef std::shared_ptr CommandOptionsPtr; - typedef std::shared_ptr CommandOptionsCPtr; + using CommandOptionsPtr = std::shared_ptr; + using CommandOptionsCPtr = std::shared_ptr; class Command : public virtual DB::Command { public: diff --git a/libpqpp/pq-connection.h b/libpqpp/pq-connection.h index 18a0198..833330b 100644 --- a/libpqpp/pq-connection.h +++ b/libpqpp/pq-connection.h @@ -5,21 +5,24 @@ #include #include #include +#include #include "pq-error.h" namespace PQ { class ConnectionError : public virtual Error, public virtual DB::ConnectionError { public: - ConnectionError(const PGconn *); + explicit ConnectionError(const PGconn *); }; class DLL_PUBLIC Connection : public DB::Connection { public: - typedef std::size_t StatementHash; - typedef std::map PreparedStatements; + using StatementHash = std::size_t; + using PreparedStatements = std::map; - Connection(const std::string & info); - ~Connection(); + explicit Connection(const std::string & info); + ~Connection() override; + + SPECIAL_MEMBERS_MOVE_RO(Connection); void beginTxInt() override; void commitTxInt() override; diff --git a/libpqpp/pq-error.h b/libpqpp/pq-error.h index c9693f7..08d86b9 100644 --- a/libpqpp/pq-error.h +++ b/libpqpp/pq-error.h @@ -8,7 +8,7 @@ namespace PQ { class Error : public AdHoc::Exception { public: - Error(const PGconn *); + explicit Error(const PGconn *); std::string message() const noexcept override; diff --git a/libpqpp/pq-mock.h b/libpqpp/pq-mock.h index eccd5ae..4218f43 100644 --- a/libpqpp/pq-mock.h +++ b/libpqpp/pq-mock.h @@ -10,16 +10,18 @@ namespace PQ { class DLL_PUBLIC Mock : public DB::MockServerDatabase { public: Mock(const std::string & master, const std::string & name, const std::vector & ss); - ~Mock(); + ~Mock() override; - DB::ConnectionPtr openConnection() const override; + SPECIAL_MEMBERS_MOVE_RO(Mock); + + [[nodiscard]] DB::ConnectionPtr openConnection() const override; protected: void CreateNewDatabase() const override; void DropDatabase() const override; void SetTablesToUnlogged() const; - bool hasUnloggedTables() const; - bool hasCopyToProgram() const; + [[nodiscard]] bool hasUnloggedTables() const; + [[nodiscard]] bool hasCopyToProgram() const; const std::filesystem::path tablespacePath; const int serverVersion; }; diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index 67ce07a..660a388 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -416,7 +416,7 @@ BOOST_AUTO_TEST_CASE( fetchAsBinary ) sel = ro->select("SELECT NULL, now()", opts); for (const auto & r : sel->as, boost::posix_time::ptime>()) { BOOST_REQUIRE(!r.value<0>()); - BOOST_REQUIRE_THROW(r.value<1>(), DB::ColumnTypeNotSupported); + BOOST_REQUIRE_THROW((void)r.value<1>(), DB::ColumnTypeNotSupported); } } @@ -461,9 +461,11 @@ BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE( connfail ) { - BOOST_REQUIRE_THROW(DB::ConnectionFactory::createNew("postgresql", "host=localhost user=no"), DB::ConnectionError); + BOOST_REQUIRE_THROW( + (void)DB::ConnectionFactory::createNew("postgresql", "host=localhost user=no"), + DB::ConnectionError); try { - DB::ConnectionFactory::createNew("postgresql", "host=localhost user=no"); + (void)DB::ConnectionFactory::createNew("postgresql", "host=localhost user=no"); } catch (const DB::ConnectionError & e) { BOOST_REQUIRE(std::string(e.what()).find("\"no\"")); -- cgit v1.2.3