Fix clang-tidy warnings.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2020-01-27 06:32:28 +01:00
parent 3a7f4ba8e2
commit 8a4f518cb9
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
15 changed files with 41 additions and 41 deletions

View File

@ -47,30 +47,30 @@ private:
//! Replace strings in text. //! Replace strings in text.
[[nodiscard]] [[nodiscard]]
string replace(string text, const replacemap &replacements) const; static string replace(string text, const replacemap &replacements);
//! Replaces characters in tags that asciidoctor doesn't like. //! Replaces characters in tags that asciidoctor doesn't like.
[[nodiscard]] [[nodiscard]]
string replace_in_tag(const string &text) const; static string replace_in_tag(const string &text);
//! Replaces characters in title that asciidoctor doesn't like. //! Replaces characters in title that asciidoctor doesn't like.
[[nodiscard]] [[nodiscard]]
string replace_in_title(const string &text) const; static string replace_in_title(const string &text);
//! Replaces characters in URI that asciidoctor doesn't like. //! Replaces characters in URI that asciidoctor doesn't like.
[[nodiscard]] [[nodiscard]]
string replace_in_uri(const string &text) const; static string replace_in_uri(const string &text);
//! Print things sorted by tag. //! Print things sorted by tag.
void print_tags(const tagmap &tags) const; void print_tags(const tagmap &tags) const;
//! Get ISO-8601 day from Database::entry. //! Get ISO-8601 day from Database::entry.
[[nodiscard]] [[nodiscard]]
string get_day(const Database::entry &entry) const; static string get_day(const Database::entry &entry);
//! Get ISO-8601 time from Database::entry. //! Get ISO-8601 time from Database::entry.
[[nodiscard]] [[nodiscard]]
string get_time(const Database::entry &entry) const; static string get_time(const Database::entry &entry);
}; };
} // namespace remwharead::Export } // namespace remwharead::Export

View File

@ -41,7 +41,7 @@ namespace remwharead::Export
private: private:
//! replaces " with "". //! replaces " with "".
[[nodiscard]] [[nodiscard]]
string quote(string field) const; static string quote(string field);
}; };
} // namespace remwharead::Export } // namespace remwharead::Export

View File

@ -68,7 +68,7 @@ protected:
* @return Sorted list of Database::entry. * @return Sorted list of Database::entry.
*/ */
[[nodiscard]] [[nodiscard]]
list<Database::entry> sort_entries(list<Database::entry> entries) const; static list<Database::entry> sort_entries(list<Database::entry> entries);
}; };
} // namespace remwharead::Export } // namespace remwharead::Export

View File

@ -110,7 +110,7 @@ private:
* @since 0.7.0 * @since 0.7.0
*/ */
[[nodiscard]] [[nodiscard]]
vector<vector<string>> parse_expression(const string &expression) const; static vector<vector<string>> parse_expression(const string &expression);
/*! /*!
* @brief Convert str to lowercase. Works with unicode. * @brief Convert str to lowercase. Works with unicode.
@ -118,7 +118,7 @@ private:
* @since 0.7.0 * @since 0.7.0
*/ */
[[nodiscard]] [[nodiscard]]
inline string to_lowercase(const string &str) const; static inline string to_lowercase(const string &str);
}; };
} // namespace remwharead } // namespace remwharead

View File

@ -132,7 +132,7 @@ private:
bool _connected; bool _connected;
[[nodiscard]] [[nodiscard]]
fs::path get_data_home() const; static fs::path get_data_home();
}; };
} // namespace remwharead } // namespace remwharead

View File

@ -151,7 +151,7 @@ protected:
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]] [[nodiscard]]
string remove_html_tags(const string &html, const string &tag = "") const; static string remove_html_tags(const string &html, const string &tag = "");
/*! /*!
* @brief Convert HTML entities to UTF-8. * @brief Convert HTML entities to UTF-8.
@ -159,7 +159,7 @@ protected:
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]] [[nodiscard]]
string unescape_html(string html) const; static string unescape_html(string html);
/*! /*!
* @brief Replace newlines with spaces. * @brief Replace newlines with spaces.
@ -167,14 +167,14 @@ protected:
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]] [[nodiscard]]
string remove_newlines(string text) const; static string remove_newlines(string text);
/*! /*!
* @brief Set proxy server. * @brief Set proxy server.
* *
* @since 0.8.5 * @since 0.8.5
*/ */
void set_proxy(); static void set_proxy();
/*! /*!
* @brief Limits text to N characters, cuts at space. * @brief Limits text to N characters, cuts at space.
@ -182,7 +182,7 @@ protected:
* @since 0.8.5 * @since 0.8.5
*/ */
[[nodiscard]] [[nodiscard]]
string cut_text(const string &text, uint16_t n_chars) const; static string cut_text(const string &text, uint16_t n_chars);
/*! /*!
* @brief Converts string to UTF-8. * @brief Converts string to UTF-8.
@ -204,6 +204,7 @@ protected:
* *
* @since 0.9.2 * @since 0.9.2
*/ */
[[nodiscard]]
bool is_html() const; bool is_html() const;
}; };
} // namespace remwharead } // namespace remwharead

View File

@ -32,12 +32,12 @@ using Poco::Util::OptionCallback;
using Poco::Util::HelpFormatter; using Poco::Util::HelpFormatter;
App::App() App::App()
: _exit_requested(false) : _exit_requested{false}
, _argument_error(false) , _argument_error{false}
, _format(export_format::undefined) , _format{export_format::undefined}
, _timespan({ time_point(), system_clock::now() }) , _timespan{{time_point(), system_clock::now()}}
, _archive(true) , _archive{true}
, _regex(false) , _regex{false}
{} {}
void App::defineOptions(OptionSet& options) void App::defineOptions(OptionSet& options)

View File

@ -44,7 +44,7 @@ protected:
void defineOptions(OptionSet& options) override; void defineOptions(OptionSet& options) override;
void handle_options(const string &name, const string &value); void handle_options(const string &name, const string &value);
void print_help(const string &option); void print_help(const string &option);
void print_version(); static void print_version();
int main(const std::vector<string> &args) override; int main(const std::vector<string> &args) override;
private: private:

View File

@ -124,7 +124,6 @@ void Export::AsciiDoc::print() const
} }
string Export::AsciiDoc::replace(string text, const replacemap &replacements) string Export::AsciiDoc::replace(string text, const replacemap &replacements)
const
{ {
for (const std::pair<const string, const string> &sr : replacements) for (const std::pair<const string, const string> &sr : replacements)
{ {
@ -137,7 +136,7 @@ string Export::AsciiDoc::replace(string text, const replacemap &replacements)
} }
return text; return text;
} }
string Export::AsciiDoc::replace_in_tag(const string &text) const string Export::AsciiDoc::replace_in_tag(const string &text)
{ {
// TODO(tastytea): Find a better solution. // TODO(tastytea): Find a better solution.
const replacemap replacements = const replacemap replacements =
@ -165,13 +164,13 @@ string Export::AsciiDoc::replace_in_tag(const string &text) const
return replace(text, replacements); return replace(text, replacements);
} }
string Export::AsciiDoc::replace_in_title(const string &text) const string Export::AsciiDoc::replace_in_title(const string &text)
{ {
// [ is implicitly escaped if the corresponding ] is. // [ is implicitly escaped if the corresponding ] is.
return replace(text, {{ "]", "\\]" }}); return replace(text, {{ "]", "\\]" }});
} }
string Export::AsciiDoc::replace_in_uri(const string &text) const string Export::AsciiDoc::replace_in_uri(const string &text)
{ {
string out; string out;
Poco::URI::encode(text, "+", out); Poco::URI::encode(text, "+", out);
@ -196,7 +195,9 @@ void Export::AsciiDoc::print_tags(const tagmap &tags) const
const std::locale loc; const std::locale loc;
const auto &coll = std::use_facet<std::collate<char>>(loc); const auto &coll = std::use_facet<std::collate<char>>(loc);
return (coll.compare( return (coll.compare(
// NOLINTNEXTLINE pointer arithmetic
&a.first[0], &a.first[0] + a.first.size(), &a.first[0], &a.first[0] + a.first.size(),
// NOLINTNEXTLINE pointer arithmetic
&b.first[0], &b.first[0] + b.first.size()) == -1); &b.first[0], &b.first[0] + b.first.size()) == -1);
}; };
std::sort(sortedtags.begin(), sortedtags.end(), compare_tags); std::sort(sortedtags.begin(), sortedtags.end(), compare_tags);
@ -235,13 +236,13 @@ void Export::AsciiDoc::print_tags(const tagmap &tags) const
_out << endl; _out << endl;
} }
string Export::AsciiDoc::get_day(const Database::entry &entry) const string Export::AsciiDoc::get_day(const Database::entry &entry)
{ {
const string datetime = timepoint_to_string(entry.datetime); const string datetime = timepoint_to_string(entry.datetime);
return datetime.substr(0, datetime.find('T')); return datetime.substr(0, datetime.find('T'));
} }
string Export::AsciiDoc::get_time(const Database::entry &entry) const string Export::AsciiDoc::get_time(const Database::entry &entry)
{ {
const string datetime = timepoint_to_string(entry.datetime); const string datetime = timepoint_to_string(entry.datetime);
return datetime.substr(datetime.find('T') + 1); return datetime.substr(datetime.find('T') + 1);

View File

@ -45,7 +45,7 @@ void Export::CSV::print() const
} }
} }
string Export::CSV::quote(string field) const string Export::CSV::quote(string field)
{ {
size_t pos = 0; size_t pos = 0;
while ((pos = field.find('"', pos)) != std::string::npos) while ((pos = field.find('"', pos)) != std::string::npos)

View File

@ -25,7 +25,7 @@ ExportBase::ExportBase(const list<Database::entry> &entries, ostream &out)
{} {}
list<Database::entry> list<Database::entry>
ExportBase::sort_entries(list<Database::entry> entries) const ExportBase::sort_entries(list<Database::entry> entries)
{ {
entries.sort([](const auto &a, const auto &b) entries.sort([](const auto &a, const auto &b)
{ {

View File

@ -37,7 +37,7 @@ Search::Search(list<Database::entry> entries)
:_entries(move(entries)) :_entries(move(entries))
{} {}
vector<vector<string>> Search::parse_expression(const string &expression) const vector<vector<string>> Search::parse_expression(const string &expression)
{ {
vector<vector<string>> searchlist; vector<vector<string>> searchlist;
const RegEx re_or("(.+?) (OR|\\|\\|) "); const RegEx re_or("(.+?) (OR|\\|\\|) ");
@ -78,7 +78,7 @@ vector<vector<string>> Search::parse_expression(const string &expression) const
return searchlist; return searchlist;
} }
string Search::to_lowercase(const string &str) const string Search::to_lowercase(const string &str)
{ {
return Poco::UTF8::toLower(str); return Poco::UTF8::toLower(str);
} }

View File

@ -33,7 +33,7 @@ using Poco::Data::Statement;
using Poco::Environment; using Poco::Environment;
Database::Database() Database::Database()
: _connected(false) : _connected{false}
{ {
try try
{ {
@ -182,7 +182,7 @@ string Database::tags_to_string(const vector<string> &tags)
return strtags; return strtags;
} }
fs::path Database::get_data_home() const fs::path Database::get_data_home()
{ {
fs::path path; fs::path path;

View File

@ -286,7 +286,7 @@ string URI::strip_html() const
return unescape_html(out); return unescape_html(out);
} }
string URI::remove_html_tags(const string &html, const string &tag) const string URI::remove_html_tags(const string &html, const string &tag)
{ {
// NOTE: I did this with regex_replace before, but libstdc++ segfaulted. // NOTE: I did this with regex_replace before, but libstdc++ segfaulted.
string out; string out;
@ -324,7 +324,7 @@ string URI::remove_html_tags(const string &html, const string &tag) const
return out; return out;
} }
string URI::unescape_html(string html) const string URI::unescape_html(string html)
{ {
// Used to convert int to utf-8 char. // Used to convert int to utf-8 char.
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> u8c; std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> u8c;
@ -648,7 +648,7 @@ archive_answer URI::archive() const
return { false, "Unknown error.", "" }; return { false, "Unknown error.", "" };
} }
string URI::remove_newlines(string text) const string URI::remove_newlines(string text)
{ {
size_t posn = 0; size_t posn = 0;
while ((posn = text.find('\n', posn)) != std::string::npos) while ((posn = text.find('\n', posn)) != std::string::npos)
@ -666,7 +666,7 @@ string URI::remove_newlines(string text) const
return text; return text;
} }
string URI::cut_text(const string &text, const uint16_t n_chars) const string URI::cut_text(const string &text, const uint16_t n_chars)
{ {
if (text.size() > n_chars) if (text.size() > n_chars)
{ {

View File

@ -17,7 +17,6 @@
#include <exception> #include <exception>
#include <string> #include <string>
#include <chrono> #include <chrono>
#include <vector>
#include <catch.hpp> #include <catch.hpp>
#include "sqlite.hpp" #include "sqlite.hpp"
#include "search.hpp" #include "search.hpp"
@ -25,7 +24,6 @@
using namespace remwharead; using namespace remwharead;
using std::string; using std::string;
using std::chrono::system_clock; using std::chrono::system_clock;
using std::vector;
SCENARIO ("Searching works correctly") SCENARIO ("Searching works correctly")
{ {