diff --git a/.clang-tidy b/.clang-tidy index d775961af01a191bc3d71f04debed688dfaa9923..7feeaaff3f943e83f8b7f5b41d8878eb9f835c87 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 8ee6b2967973d06d111498edd70480e41cee8320..01e724f303f58ffb1420f9159dd37f7ad19b866c 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 36bdd47efcaadb25789890695010569a32342711..6afffad396990dc7ae38217fa9089adc9530e3ab 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<ResizeDecorator>( // 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<ComponentBase>(); } @@ -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 f421a2e6602f2927eaf4b1a2b13dfc6a18dfd373..cb220d0abe9494c3b7c05653096bf23cf1084ecf 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 0bc82c9684db49d94bbf39ec25a5134a80a6780b..8ddfd02dc41c23091d5a4f4042e847b1eae0646b 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<Interval, 116> g_full_width_characters = {{ +constexpr std::array<Interval, 116> 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<WordBreakPropertyInterval, 993> +constexpr std::array<WordBreakPropertyInterval, 993> 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;