diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-22 16:42:06 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-22 16:42:06 +0100 |
commit | 2317b4608821b03da0cc288d06b9c0bdb6b60239 (patch) | |
tree | 7dd46e3c2c5601e603baa7defa057cd4d41fc4c9 | |
parent | Move everything into more sensible places (diff) | |
download | mygrate-2317b4608821b03da0cc288d06b9c0bdb6b60239.tar.bz2 mygrate-2317b4608821b03da0cc288d06b9c0bdb6b60239.tar.xz mygrate-2317b4608821b03da0cc288d06b9c0bdb6b60239.zip |
Pass linter checks
Except IWYU, doesn't like the C++20 CTF.
-rw-r--r-- | iwyu.json | 18 | ||||
-rw-r--r-- | lib/Jamfile.jam | 1 | ||||
-rw-r--r-- | lib/bitset.h | 2 | ||||
-rw-r--r-- | lib/eventHandlerBase.cpp | 2 | ||||
-rw-r--r-- | lib/input/mysqlConn.cpp | 4 | ||||
-rw-r--r-- | lib/input/replStream.cpp | 9 | ||||
-rw-r--r-- | lib/input/replStream.h | 6 | ||||
-rw-r--r-- | lib/mysql_types.cpp | 10 | ||||
-rw-r--r-- | lib/mysql_types.h | 5 | ||||
-rw-r--r-- | lib/output/dumpToConsole.cpp | 6 | ||||
-rw-r--r-- | lib/output/dumpToConsole.h | 2 | ||||
-rw-r--r-- | lib/rawDataReader.cpp | 5 | ||||
-rw-r--r-- | lib/rawDataReader.h | 8 | ||||
-rw-r--r-- | lib/row.cpp | 6 | ||||
-rw-r--r-- | lib/row.h | 9 | ||||
-rw-r--r-- | lib/streamSupport.cpp | 2 | ||||
-rw-r--r-- | test/test-bitset.cpp | 6 | ||||
-rw-r--r-- | test/test-rawDataReader.cpp | 16 | ||||
-rw-r--r-- | test/test-streams.cpp | 19 |
19 files changed, 95 insertions, 41 deletions
@@ -9,7 +9,7 @@ }, { "include": [ - "<mariadb_com.h>", + "@.(mysql|mariadb_(com|ctype|dyncol|stmt|version))\\.h.", "private", "<mysql.h>", "public" @@ -17,6 +17,22 @@ }, { "include": [ + "@.mariadb_rpl\\.h.", + "private", + "\"mariadb_repl.h\"", + "public" + ] + }, + { + "include": [ + "<boost/mpl/aux_/preprocessed/gcc/list.hpp>", + "private", + "<boost/mpl/list.hpp>", + "public" + ] + }, + { + "include": [ "<boost/test/unit_test_suite.hpp>", "private", "<boost/test/unit_test.hpp>", diff --git a/lib/Jamfile.jam b/lib/Jamfile.jam index 02374c9..05699a8 100644 --- a/lib/Jamfile.jam +++ b/lib/Jamfile.jam @@ -2,6 +2,7 @@ lib mygrate : [ glob-tree *.cpp ] : <link>static + <include>. <use>..//libmariadb : : <include>. diff --git a/lib/bitset.h b/lib/bitset.h index 40ee3ed..b604ccf 100644 --- a/lib/bitset.h +++ b/lib/bitset.h @@ -2,7 +2,7 @@ #define MYGRATE_BITSET_H #include <cstddef> -#include <cstdint> +#include <iterator> #include <span> namespace MyGrate { diff --git a/lib/eventHandlerBase.cpp b/lib/eventHandlerBase.cpp index 7f9b2d4..777c746 100644 --- a/lib/eventHandlerBase.cpp +++ b/lib/eventHandlerBase.cpp @@ -1,4 +1,6 @@ #include "eventHandlerBase.h" +#include <type_traits> +#include <utility> namespace MyGrate { void diff --git a/lib/input/mysqlConn.cpp b/lib/input/mysqlConn.cpp index 38feb35..6c00628 100644 --- a/lib/input/mysqlConn.cpp +++ b/lib/input/mysqlConn.cpp @@ -2,7 +2,9 @@ #include <stdexcept> namespace MyGrate::Input { - MySQLConn::MySQLConn(const char * const host, const char * const user, const char * const pass, unsigned short port) + MySQLConn::MySQLConn( + const char * const host, const char * const user, const char * const pass, unsigned short port) : + st_mysql {} { mysql_init(this); if (!mysql_real_connect(this, host, user, pass, "", port, nullptr, 0)) { diff --git a/lib/input/replStream.cpp b/lib/input/replStream.cpp index 88c3caf..c894941 100644 --- a/lib/input/replStream.cpp +++ b/lib/input/replStream.cpp @@ -1,6 +1,11 @@ #include "replStream.h" -#include "../eventHandlers.h" -#include "../mariadb_repl.h" +#include "mariadb_repl.h" +#include <eventHandlerBase.h> +#include <eventHandlers.h> +#include <memory> +#include <mysql.h> +#include <stdexcept> +#include <utility> namespace MyGrate::Input { void diff --git a/lib/input/replStream.h b/lib/input/replStream.h index 983d9d3..4b1a7b6 100644 --- a/lib/input/replStream.h +++ b/lib/input/replStream.h @@ -1,8 +1,12 @@ #ifndef MYGRATE_INPUT_REPLSTREAM_H #define MYGRATE_INPUT_REPLSTREAM_H -#include "../eventSourceBase.h" #include "mysqlConn.h" +#include <eventSourceBase.h> + +namespace MyGrate { + class EventHandlerBase; +} namespace MyGrate::Input { class ReplicationStream : public EventSourceBase, MySQLConn { diff --git a/lib/mysql_types.cpp b/lib/mysql_types.cpp index b61de08..a4641ba 100644 --- a/lib/mysql_types.cpp +++ b/lib/mysql_types.cpp @@ -1,8 +1,10 @@ #include "mysql_types.h" #include "helpers.h" #include "rawDataReader.h" -#include <iostream> +#include <algorithm> +#include <array> #include <stdexcept> +#include <string> namespace MyGrate::MySQL { typename Type<MYSQL_TYPE_NULL, false>::C @@ -96,13 +98,11 @@ namespace MyGrate::MySQL { const auto realtype {md.readValue<enum_field_types, 1>()}; \ const auto lenlen {md.readValue<uint8_t>()}; \ switch (realtype) { \ - case MYSQL_TYPE_ENUM: { \ + case MYSQL_TYPE_ENUM: \ + case MYSQL_TYPE_VAR_STRING: \ return data.viewValue<std::string_view>(lenlen); \ - break; \ - } \ default: \ throw std::logic_error("Not implemented: sub-type: " + std::to_string(realtype)); \ - break; \ } \ throw std::logic_error("Didn't return a value: " + std::to_string(realtype)); \ } diff --git a/lib/mysql_types.h b/lib/mysql_types.h index ec578f7..af45b4f 100644 --- a/lib/mysql_types.h +++ b/lib/mysql_types.h @@ -2,16 +2,15 @@ #define MYGRATE_MYSQL_TYPES_H #include "bitset.h" -#include <array> #include <cstddef> #include <cstdint> #include <ctime> -#include <mysql.h> // IWYU pragma: keep +#include <mysql.h> #include <span> #include <string_view> #include <variant> -#include <mariadb_rpl.h> +struct timespec; namespace MyGrate { class RawDataReader; diff --git a/lib/output/dumpToConsole.cpp b/lib/output/dumpToConsole.cpp index 6ece800..4cc9cc9 100644 --- a/lib/output/dumpToConsole.cpp +++ b/lib/output/dumpToConsole.cpp @@ -1,7 +1,7 @@ #include "dumpToConsole.h" -#include "../compileTimeFormatter.h" -#include "../row.h" -#include "../streamSupport.h" +#include <compileTimeFormatter.h> +#include <row.h> +#include <streamSupport.h> namespace MyGrate::Output { void diff --git a/lib/output/dumpToConsole.h b/lib/output/dumpToConsole.h index 98769a6..d03c795 100644 --- a/lib/output/dumpToConsole.h +++ b/lib/output/dumpToConsole.h @@ -1,7 +1,7 @@ #ifndef MYGRATE_OUTPUT_DUMPTOCONSOLE_H #define MYGRATE_OUTPUT_DUMPTOCONSOLE_H -#include "../eventHandlerBase.h" +#include <eventHandlerBase.h> namespace MyGrate::Output { class DumpToConsole : public MyGrate::EventHandlerBase { diff --git a/lib/rawDataReader.cpp b/lib/rawDataReader.cpp index 2dd87a9..90e227a 100644 --- a/lib/rawDataReader.cpp +++ b/lib/rawDataReader.cpp @@ -1,9 +1,4 @@ #include "rawDataReader.h" -#include "helpers.h" -#include "streamSupport.h" -#include <cstring> -#include <iomanip> -#include <iostream> namespace MyGrate { RawDataReader::RawDataReader(const void * const d, std::size_t l) : diff --git a/lib/rawDataReader.h b/lib/rawDataReader.h index 0ed2847..906eaef 100644 --- a/lib/rawDataReader.h +++ b/lib/rawDataReader.h @@ -2,17 +2,11 @@ #define MYGRATE_RAW_DATA_READER_H #include "helpers.h" -#include <array> +#include "mariadb_repl.h" #include <cstddef> #include <cstdint> #include <cstring> -#include <ctime> -#include <mysql.h> // IWYU pragma: keep -#include <span> #include <stdexcept> -#include <string_view> - -#include <mariadb_rpl.h> namespace MyGrate { struct PackedInteger { diff --git a/lib/row.cpp b/lib/row.cpp index 45e2959..65ac591 100644 --- a/lib/row.cpp +++ b/lib/row.cpp @@ -1,4 +1,10 @@ #include "row.h" +#include "bitset.h" +#include "mariadb_repl.h" +#include "rawDataReader.h" +#include <cstddef> +#include <mysql.h> +#include <span> #include <stdexcept> #include <string> @@ -2,8 +2,13 @@ #define MYGRATE_ROW_H #include "mysql_types.h" -#include "rawDataReader.h" -#include <functional> +#include <utility> +#include <vector> +namespace MyGrate { + class RawDataReader; +} +struct st_mariadb_rpl_rows_event; +struct st_mariadb_rpl_table_map_event; namespace MyGrate { class Row : public std::vector<MySQL::FieldValue> { diff --git a/lib/streamSupport.cpp b/lib/streamSupport.cpp index 541b191..1e5258c 100644 --- a/lib/streamSupport.cpp +++ b/lib/streamSupport.cpp @@ -11,7 +11,7 @@ namespace std { std::ostream & operator<<(std::ostream & s, const MARIADB_STRING & str) { - return s.write(str.str, str.length); + return s << std::string_view(str.str, str.length); } std::ostream & diff --git a/test/test-bitset.cpp b/test/test-bitset.cpp index 15e43d6..02b3893 100644 --- a/test/test-bitset.cpp +++ b/test/test-bitset.cpp @@ -1,10 +1,12 @@ #define BOOST_TEST_MODULE BitSet -#include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> #include "helpers.h" +#include <array> #include <bitset.h> #include <bitset> +#include <cstddef> +#include <span> using namespace MyGrate; @@ -14,7 +16,7 @@ BOOST_TEST_DONT_PRINT_LOG_VALUE(BitSet::Iterator); BOOST_AUTO_TEST_CASE(bitset) { - std::byte bytes[3] {0x00_b, 0xFF_b, 0xa1_b}; + constexpr std::array<std::byte, 3> bytes {0x00_b, 0xFF_b, 0xa1_b}; BitSet bs {bytes}; BOOST_REQUIRE_EQUAL(bs.size(), 24); diff --git a/test/test-rawDataReader.cpp b/test/test-rawDataReader.cpp index 4ac0a8a..b211fe3 100644 --- a/test/test-rawDataReader.cpp +++ b/test/test-rawDataReader.cpp @@ -3,10 +3,20 @@ #include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> +#include "bitset.h" #include "helpers.h" +#include "mariadb_repl.h" +#include <cstddef> +#include <cstdint> +#include <mysql.h> #include <mysql_types.h> #include <rawDataReader.h> +#include <stdexcept> #include <streamSupport.h> +#include <string> +#include <string_view> +#include <tuple> +#include <vector> using namespace MyGrate; @@ -147,10 +157,10 @@ BOOST_DATA_TEST_CASE(read_field_type, BOOST_AUTO_TEST_CASE(rdr_from_MARIADB_STRING) { - char buf[5] = "test"; - MARIADB_STRING str {buf, strlen(buf)}; + std::string buf {"test"}; + MARIADB_STRING str {buf.data(), buf.length()}; RawDataReader rdr {str}; - BOOST_CHECK_EQUAL(rdr.viewValue<std::string_view>(4), "test"); + BOOST_CHECK_EQUAL(rdr.viewValue<std::string_view>(buf.length()), buf); } using SimpleTypes = boost::mpl::list<std::byte, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, diff --git a/test/test-streams.cpp b/test/test-streams.cpp index 9e79bd6..3958e36 100644 --- a/test/test-streams.cpp +++ b/test/test-streams.cpp @@ -2,7 +2,20 @@ #include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> +#include "bitset.h" #include "helpers.h" +#include "mariadb_repl.h" +#include "mysql_types.h" +#include <array> +#include <cstddef> +#include <ctime> +#include <iosfwd> +#include <string> +#include <string_view> +#include <tuple> +#include <vector> +struct timespec; +struct tm; #include <streamSupport.h> BOOST_FIXTURE_TEST_SUITE(stream, std::stringstream); @@ -56,7 +69,7 @@ BOOST_DATA_TEST_CASE(tss, *this << in; BOOST_CHECK_EQUAL(this->str(), exp); } -constexpr std::byte somebits[3] {0x00_b, 0xFF_b, 0xa1_b}; +constexpr std::array<std::byte, 3> somebits {0x00_b, 0xFF_b, 0xa1_b}; BOOST_DATA_TEST_CASE(bss, boost::unit_test::data::make<ToStream<MyGrate::BitSet>>({ {{MyGrate::BitSet {somebits}}, "[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1]"}, @@ -69,8 +82,8 @@ BOOST_DATA_TEST_CASE(bss, BOOST_AUTO_TEST_CASE(mariadb_string) { - char buf[5] = "test"; - MARIADB_STRING str {buf, strlen(buf)}; + std::string buf {"test"}; + MARIADB_STRING str {buf.data(), buf.length()}; *this << str; BOOST_CHECK_EQUAL(this->str(), buf); } |