1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

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 { class builder {
public: public:
explicit builder(const bar_settings bar); explicit builder(const bar_settings& bar);
string flush(); string flush();
void append(string text); 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 run(bool writeback = false);
bool enqueue(event&& evt); bool enqueue(event&& evt);
bool enqueue(string&& input); bool enqueue(string&& input_data);
protected: protected:
void read_events(); void read_events();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -104,7 +104,7 @@ namespace modules {
} else if (find(whitelist.begin(), whitelist.end(), tag) != whitelist.end()) { } else if (find(whitelist.begin(), whitelist.end(), tag) != whitelist.end()) {
continue; continue;
} else { } 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 + "\"");
} }
} }