refactor(clang-tidy): Apply fixes

This commit is contained in:
Michael Carlberg 2016-12-31 04:32:11 +01:00
parent ad0af86a7b
commit e3a51b235a
9 changed files with 38 additions and 38 deletions

View File

@ -20,7 +20,7 @@ using namespace drawtypes;
class builder {
public:
explicit builder(const bar_settings bar);
explicit builder(const bar_settings& bar);
string flush();
void append(string text);

View File

@ -57,7 +57,7 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, sig_ev::exit
bool run(bool writeback = false);
bool enqueue(event&& evt);
bool enqueue(string&& input);
bool enqueue(string&& input_data);
protected:
void read_events();

View File

@ -14,9 +14,9 @@ POLYBAR_NS
namespace drawtypes {
struct token {
string token;
size_t min;
size_t max;
string suffix{""};
size_t min{0_z};
size_t max{0_z};
string suffix{""s};
};
class label;
@ -35,15 +35,15 @@ namespace drawtypes {
string m_underline{};
string m_overline{};
int m_font{0};
side_values m_padding{0,0};
side_values m_margin{0,0};
size_t m_maxlen{0};
side_values m_padding{0U,0U};
side_values m_margin{0U,0U};
size_t m_maxlen{0_z};
bool m_ellipsis{true};
explicit label(string text, int font) : m_font(font), m_text(text), m_tokenized(m_text) {}
explicit label(string text, string foreground = "", string background = "", string underline = "",
string overline = "", int font = 0, struct side_values padding = {0,0}, struct side_values margin = {0,0},
size_t maxlen = 0, bool ellipsis = true, vector<token>&& tokens = {})
explicit label(string text, string foreground = ""s, string background = ""s, string underline = ""s,
string overline = ""s, int font = 0, struct side_values padding = {0U,0U}, struct side_values margin = {0U,0U},
size_t maxlen = 0_z, bool ellipsis = true, vector<token>&& tokens = {})
: m_foreground(foreground)
, m_background(background)
, m_underline(underline)
@ -72,11 +72,11 @@ namespace drawtypes {
const vector<token> m_tokens{};
};
label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = "");
label_t load_optional_label(const config& conf, string section, string name, string def = "");
label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = ""s);
label_t load_optional_label(const config& conf, string section, string name, string def = ""s);
icon_t load_icon(const config& conf, string section, string name, bool required = true, string def = "");
icon_t load_optional_icon(const config& conf, string section, string name, string def = "");
icon_t load_icon(const config& conf, string section, string name, bool required = true, string def = ""s);
icon_t load_optional_icon(const config& conf, string section, string name, string def = ""s);
}
POLYBAR_NS_END

View File

@ -66,8 +66,8 @@ class fd_streambuf : public std::streambuf {
private:
file_descriptor m_fd;
char m_out[BUFSIZ];
char m_in[BUFSIZ - 1];
char m_out[BUFSIZ]{'\0'};
char m_in[BUFSIZ - 1]{'\0'};
};
template <typename StreamType = std::ostream>

View File

@ -12,7 +12,7 @@ POLYBAR_NS
#define BUILDER_SPACE_TOKEN "%__"
#endif
builder::builder(const bar_settings bar) : m_bar(bar) {
builder::builder(const bar_settings& bar) : m_bar(bar) {
m_tags[syntaxtag::A] = 0;
m_tags[syntaxtag::B] = 0;
m_tags[syntaxtag::F] = 0;
@ -311,7 +311,7 @@ void builder::space() {
* Remove trailing space
*/
void builder::remove_trailing_space(size_t len) {
if (len == 0_z || len > m_output.size()) {
if (len == 0_z || len > m_output.size()) {
return;
} else if (m_output.substr(m_output.size() - len) == string(len, ' ')) {
m_output.erase(m_output.size() - len);

View File

@ -11,7 +11,7 @@ POLYBAR_NS
/**
* Convert string
*/
const char* logger::convert(string arg) const {
const char* logger::convert(string arg) const { // NOLINT
return arg.c_str();
}

View File

@ -39,10 +39,10 @@ namespace drawtypes {
for (auto&& tok : m_tokens) {
if (token == tok.token) {
if (tok.max != 0 && replacement.length() > tok.max) {
if (tok.max != 0_z && replacement.length() > tok.max) {
replacement = replacement.erase(tok.max) + tok.suffix;
} else if (tok.min != 0 && replacement.length() < tok.min) {
replacement.insert(0, tok.min - replacement.length(), ' ');
} else if (tok.min != 0_z && replacement.length() < tok.min) {
replacement.insert(0_z, tok.min - replacement.length(), ' ');
}
m_tokenized = string_util::replace_all(m_tokenized, token, move(replacement));
}
@ -65,19 +65,19 @@ namespace drawtypes {
if (label->m_font != 0) {
m_font = label->m_font;
}
if (label->m_padding.left != 0) {
if (label->m_padding.left != 0U) {
m_padding.left = label->m_padding.left;
}
if (label->m_padding.right != 0) {
if (label->m_padding.right != 0U) {
m_padding.right = label->m_padding.right;
}
if (label->m_margin.left != 0) {
if (label->m_margin.left != 0U) {
m_margin.left = label->m_margin.left;
}
if (label->m_margin.right != 0) {
if (label->m_margin.right != 0U) {
m_margin.right = label->m_margin.right;
}
if (label->m_maxlen != 0) {
if (label->m_maxlen != 0_z) {
m_maxlen = label->m_maxlen;
m_ellipsis = label->m_ellipsis;
}
@ -99,19 +99,19 @@ namespace drawtypes {
if (m_font == 0 && label->m_font != 0) {
m_font = label->m_font;
}
if (m_padding.left == 0 && label->m_padding.left != 0) {
if (m_padding.left == 0U && label->m_padding.left != 0U) {
m_padding.left = label->m_padding.left;
}
if (m_padding.right == 0 && label->m_padding.right != 0) {
if (m_padding.right == 0U && label->m_padding.right != 0U) {
m_padding.right = label->m_padding.right;
}
if (m_margin.left == 0 && label->m_margin.left != 0) {
if (m_margin.left == 0U && label->m_margin.left != 0U) {
m_margin.left = label->m_margin.left;
}
if (m_margin.right == 0 && label->m_margin.right != 0) {
if (m_margin.right == 0U && label->m_margin.right != 0U) {
m_margin.right = label->m_margin.right;
}
if (m_maxlen == 0 && label->m_maxlen != 0) {
if (m_maxlen == 0_z && label->m_maxlen != 0_z) {
m_maxlen = label->m_maxlen;
m_ellipsis = label->m_ellipsis;
}
@ -144,7 +144,7 @@ namespace drawtypes {
}
const auto get_left_right = [&](string key) {
auto value = conf.get(section, key, 0);
auto value = conf.get(section, key, 0U);
auto left = conf.get(section, key + "-left", value);
auto right = conf.get(section, key + "-right", value);
return side_values{static_cast<uint16_t>(left), static_cast<uint16_t>(right)};
@ -165,7 +165,7 @@ namespace drawtypes {
}
line.erase(start, end - start + 1);
tokens.emplace_back(token{token_str, 0, 0});
tokens.emplace_back(token{token_str, 0_z, 0_z});
auto& token = tokens.back();
// find min delimiter
@ -196,7 +196,7 @@ namespace drawtypes {
// ignore max lengths less than min
if (token.max < token.min) {
token.max = 0;
token.max = 0_z;
}
// find suffix delimiter

View File

@ -1,6 +1,6 @@
#include <fstream>
#include <istream>
#include <iomanip>
#include <istream>
#include "modules/memory.hpp"

View File

@ -104,7 +104,7 @@ namespace modules {
} else if (find(whitelist.begin(), whitelist.end(), tag) != whitelist.end()) {
continue;
} else {
throw undefined_format_tag(tag + " is not a valid format tag for \""+ name +"\"");
throw undefined_format_tag(tag + " is not a valid format tag for \"" + name + "\"");
}
}