From 44da14755d4e4b31bc118dc946c8553597bc237e Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sun, 4 Dec 2016 04:11:47 +0100 Subject: [PATCH] refactor(clang-tidy): Apply fixes --- include/components/builder.hpp | 2 +- include/utils/string.hpp | 4 ++-- include/x11/tray.hpp | 2 +- include/x11/xkb.hpp | 2 +- src/components/builder.cpp | 2 +- src/components/eventloop.cpp | 2 +- src/components/screen.cpp | 4 ++-- src/modules/bspwm.cpp | 21 ++++++++++++++------- src/modules/meta/base.cpp | 2 +- src/modules/xworkspaces.cpp | 2 +- src/x11/tray.cpp | 1 - 11 files changed, 25 insertions(+), 19 deletions(-) diff --git a/include/components/builder.hpp b/include/components/builder.hpp index fce6d359..3a41d382 100644 --- a/include/components/builder.hpp +++ b/include/components/builder.hpp @@ -32,7 +32,7 @@ class builder { void node(string str, bool add_space = false); void node(string str, int font_index, bool add_space = false); void node(const label_t& label, bool add_space = false); - void node_repeat(string str, size_t n, bool add_space = false); + void node_repeat(const string& str, size_t n, bool add_space = false); void node_repeat(const label_t& label, size_t n, bool add_space = false); void offset(int pixels = 0); void space(int width = DEFAULT_SPACING); diff --git a/include/utils/string.hpp b/include/utils/string.hpp index 72f7bc3b..99e07f73 100644 --- a/include/utils/string.hpp +++ b/include/utils/string.hpp @@ -16,9 +16,9 @@ namespace string_util { string upper(const string& s); string lower(const string& s); bool compare(const string& s1, const string& s2); - string replace(const string& haystack, const string& needle, const string& replacement, size_t start = 0, + string replace(const string& haystack, const string& needle, const string& reply, size_t start = 0, size_t end = string::npos); - string replace_all(const string& haystack, const string& needle, const string& replacement, size_t start = 0, + string replace_all(const string& haystack, const string& needle, const string& reply, size_t start = 0, size_t end = string::npos); string squeeze(const string& haystack, char needle); string strip(const string& haystack, char needle); diff --git a/include/x11/tray.hpp b/include/x11/tray.hpp index 38cd0b84..7a3e5238 100644 --- a/include/x11/tray.hpp +++ b/include/x11/tray.hpp @@ -130,7 +130,7 @@ class tray_manager : public xpp::event::sink(layouts_)), indicators(forward(indicators_)) {} const indicator& get(const indicator::type& i) const; - void set(uint32_t indicator_state); + void set(uint32_t state); bool on(const indicator::type&) const; const string group_name(size_t index = 0) const; diff --git a/src/components/builder.cpp b/src/components/builder.cpp index fa70ca61..0ccf2775 100644 --- a/src/components/builder.cpp +++ b/src/components/builder.cpp @@ -250,7 +250,7 @@ void builder::node(const label_t& label, bool add_space) { /** * Repeat text string n times */ -void builder::node_repeat(string str, size_t n, bool add_space) { +void builder::node_repeat(const string& str, size_t n, bool add_space) { string text; while (n--) { text += str; diff --git a/src/components/eventloop.cpp b/src/components/eventloop.cpp index 59b693b3..e4a9e0d1 100644 --- a/src/components/eventloop.cpp +++ b/src/components/eventloop.cpp @@ -1,8 +1,8 @@ #include #include "components/eventloop.hpp" -#include "components/types.hpp" #include "components/signals.hpp" +#include "components/types.hpp" #include "utils/string.hpp" #include "utils/time.hpp" #include "x11/color.hpp" diff --git a/src/components/screen.cpp b/src/components/screen.cpp index abd32426..00b63342 100644 --- a/src/components/screen.cpp +++ b/src/components/screen.cpp @@ -2,11 +2,11 @@ #include #include "components/config.hpp" +#include "components/eventloop.hpp" #include "components/logger.hpp" #include "components/screen.hpp" -#include "components/types.hpp" #include "components/signals.hpp" -#include "components/eventloop.hpp" +#include "components/types.hpp" #include "x11/connection.hpp" #include "x11/randr.hpp" #include "x11/winspec.hpp" diff --git a/src/modules/bspwm.cpp b/src/modules/bspwm.cpp index 62e780f7..6e1ea8d4 100644 --- a/src/modules/bspwm.cpp +++ b/src/modules/bspwm.cpp @@ -15,10 +15,12 @@ namespace { uint32_t make_mask(bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) { uint32_t mask{0U}; - if (static_cast(s1)) + if (static_cast(s1)) { mask |= 1 << (static_cast(s1) - 1); - if (static_cast(s2)) + } + if (static_cast(s2)) { mask |= 1 << (static_cast(s2) - 1); + } return mask; } @@ -327,16 +329,21 @@ namespace modules { auto label = m_statelabels.at(workspace_mask)->clone(); if (!m_monitors.back()->focused) { - if (m_statelabels[make_mask(state::DIMMED)]) + if (m_statelabels[make_mask(state::DIMMED)]) { label->replace_defined_values(m_statelabels[make_mask(state::DIMMED)]); - if (workspace_mask & make_mask(state::EMPTY)) + } + if (workspace_mask & make_mask(state::EMPTY)) { label->replace_defined_values(m_statelabels[make_mask(state::DIMMED, state::EMPTY)]); - if (workspace_mask & make_mask(state::OCCUPIED)) + } + if (workspace_mask & make_mask(state::OCCUPIED)) { label->replace_defined_values(m_statelabels[make_mask(state::DIMMED, state::OCCUPIED)]); - if (workspace_mask & make_mask(state::FOCUSED)) + } + if (workspace_mask & make_mask(state::FOCUSED)) { label->replace_defined_values(m_statelabels[make_mask(state::DIMMED, state::FOCUSED)]); - if (workspace_mask & make_mask(state::URGENT)) + } + if (workspace_mask & make_mask(state::URGENT)) { label->replace_defined_values(m_statelabels[make_mask(state::DIMMED, state::URGENT)]); + } } label->reset_tokens(); diff --git a/src/modules/meta/base.cpp b/src/modules/meta/base.cpp index 6b14aad9..c24237a8 100644 --- a/src/modules/meta/base.cpp +++ b/src/modules/meta/base.cpp @@ -1,8 +1,8 @@ #include #include "components/builder.hpp" -#include "modules/meta/base.hpp" #include "drawtypes/label.hpp" +#include "modules/meta/base.hpp" POLYBAR_NS diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index d6366973..f4cf19bc 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -3,9 +3,9 @@ #include "drawtypes/iconset.hpp" #include "drawtypes/label.hpp" #include "modules/xworkspaces.hpp" +#include "utils/math.hpp" #include "x11/atoms.hpp" #include "x11/connection.hpp" -#include "utils/math.hpp" #include "modules/meta/base.inl" #include "modules/meta/static_module.inl" diff --git a/src/x11/tray.cpp b/src/x11/tray.cpp index 7613c500..fc70d637 100644 --- a/src/x11/tray.cpp +++ b/src/x11/tray.cpp @@ -677,7 +677,6 @@ void tray_manager::notify_clients_delayed(chrono::duration d this_thread::sleep_for(delay); notify_clients(); }); - } /**