diff --git a/.clang-tidy b/.clang-tidy index d775961..7feeaaf 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,6 @@ --- Checks: "*, + -*-macro-usage, -*-magic-numbers, -*-narrowing-conversions -*-unnecessary-value-param, @@ -22,7 +23,9 @@ Checks: "*, -readability-identifier-length, -readability-implicit-bool-conversion, -readability-non-const-parameter, + -readability-simplify-boolean-expr, -readability-static-accessed-through-instance, + -readability-use-anyofallof, -zircon-*, " WarningsAsErrors: '' diff --git a/src/ftxui/component/container.cpp b/src/ftxui/component/container.cpp index 8ee6b29..01e724f 100644 --- a/src/ftxui/component/container.cpp +++ b/src/ftxui/component/container.cpp @@ -237,7 +237,7 @@ class TabContainer : public ContainerBase { class StackedContainer : public ContainerBase { public: - StackedContainer(Components children) + explicit StackedContainer(Components children) : ContainerBase(std::move(children), nullptr) {} private: @@ -252,7 +252,7 @@ class StackedContainer : public ContainerBase { } bool Focusable() const final { - for (auto& child : children_) { + for (const auto& child : children_) { if (child->Focusable()) { return true; } @@ -261,13 +261,14 @@ class StackedContainer : public ContainerBase { } Component ActiveChild() final { - if (children_.size() == 0) + if (children_.empty()) { return nullptr; + } return children_[0]; } void SetActiveChild(ComponentBase* child) final { - if (children_.size() == 0) { + if (children_.empty()) { return; } diff --git a/src/ftxui/component/window.cpp b/src/ftxui/component/window.cpp index 36bdd47..6afffad 100644 --- a/src/ftxui/component/window.cpp +++ b/src/ftxui/component/window.cpp @@ -91,7 +91,7 @@ Element DefaultRenderState(const WindowRenderState& state) { element = window(text(state.title), element); element |= clear_under; - Color color = Color::Red; + const Color color = Color::Red; element = std::make_shared( // element, // @@ -107,7 +107,7 @@ Element DefaultRenderState(const WindowRenderState& state) { class WindowImpl : public ComponentBase, public WindowOptions { public: - WindowImpl(WindowOptions option) : WindowOptions(std::move(option)) { + explicit WindowImpl(WindowOptions option) : WindowOptions(std::move(option)) { if (!inner) { inner = Make(); } @@ -118,7 +118,7 @@ class WindowImpl : public ComponentBase, public WindowOptions { Element Render() final { auto element = ComponentBase::Render(); - bool captureable = + const bool captureable = captured_mouse_ || ScreenInteractive::Active()->CaptureMouse(); const WindowRenderState state = { diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index f421a2e..cb220d0 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -78,7 +78,7 @@ void UpdatePixelStyle(const Screen* screen, } // Bold - if (FTXUI_UNLIKELY(next.bold != prev.bold || next.dim != prev.dim)) { + if (FTXUI_UNLIKELY((next.bold ^ prev.bold) | (next.dim ^ prev.dim))) { // BOLD_AND_DIM_RESET: ss << ((prev.bold && !next.bold) || (prev.dim && !next.dim) ? "\x1B[22m" : ""); diff --git a/src/ftxui/screen/string.cpp b/src/ftxui/screen/string.cpp index 0bc82c9..8ddfd02 100644 --- a/src/ftxui/screen/string.cpp +++ b/src/ftxui/screen/string.cpp @@ -24,7 +24,7 @@ struct Interval { }; // As of Unicode 13.0.0 -static constexpr std::array g_full_width_characters = {{ +constexpr std::array g_full_width_characters = {{ {0x01100, 0x0115f}, {0x0231a, 0x0231b}, {0x02329, 0x0232a}, {0x023e9, 0x023ec}, {0x023f0, 0x023f0}, {0x023f3, 0x023f3}, {0x025fd, 0x025fe}, {0x02614, 0x02615}, {0x02648, 0x02653}, @@ -75,7 +75,7 @@ struct WordBreakPropertyInterval { // Properties from: // https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt -static constexpr std::array +constexpr std::array g_word_break_intervals = {{ {0x0000A, 0x0000A, WBP::LF}, {0x0000B, 0x0000C, WBP::Newline}, @@ -1090,7 +1090,7 @@ constexpr auto g_extend_characters{[]() constexpr { size_t index = 0; for (auto interval : g_word_break_intervals) { if (interval.property == WBP::Extend) { - result[index++] = {interval.first, interval.last}; + result[index++] = {interval.first, interval.last}; // NOLINT } } return result;