From 8226c5aea7c740346e11a8a9234d40a87fd4435c Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Sun, 28 Aug 2022 21:30:01 +0200 Subject: [PATCH] Fix clang-tidy. (#469) --- .clang-tidy | 10 ++++++---- src/ftxui/component/component_options.cpp | 6 +++++- src/ftxui/component/modal.cpp | 3 +-- src/ftxui/component/radiobox.cpp | 3 +-- src/ftxui/dom/separator.cpp | 2 -- src/ftxui/screen/color.cpp | 9 ++++----- src/ftxui/screen/screen.cpp | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 6459e59..494b17a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -8,14 +8,16 @@ Checks: "*, -llvm*, -modernize-use-trailing-return-type, -zircon-*, - -readability-else-after-return, - -readability-static-accessed-through-instance, - -readability-avoid-const-params-in-decls, + -bugprone-easily-swappable-parameters, -cppcoreguidelines-non-private-member-variables-in-classes, + -misc-no-recursion, -misc-non-private-member-variables-in-classes, -modernize-use-nodiscard, - -misc-no-recursion, + -readability-avoid-const-params-in-decls, + -readability-else-after-return, + -readability-identifier-length, -readability-implicit-bool-conversion, + -readability-static-accessed-through-instance, " WarningsAsErrors: '' HeaderFilterRegex: '' diff --git a/src/ftxui/component/component_options.cpp b/src/ftxui/component/component_options.cpp index 5e29d4b..57a2c14 100644 --- a/src/ftxui/component/component_options.cpp +++ b/src/ftxui/component/component_options.cpp @@ -164,7 +164,11 @@ ButtonOption ButtonOption::Animated(Color color) { /// @brief Create a ButtonOption, using animated colors. // static ButtonOption ButtonOption::Animated(Color background, Color foreground) { - return ButtonOption::Animated(background, foreground, foreground, background); + return ButtonOption::Animated( + /*bakground=*/background, + /*foreground=*/foreground, + /*background_active=*/foreground, + /*foreground_active=*/background); } /// @brief Create a ButtonOption, using animated colors. diff --git a/src/ftxui/component/modal.cpp b/src/ftxui/component/modal.cpp index 509a6bd..e35e67d 100644 --- a/src/ftxui/component/modal.cpp +++ b/src/ftxui/component/modal.cpp @@ -19,7 +19,6 @@ Component Modal(Component main, Component modal, const bool* show_modal) { : main_(std::move(main)), modal_(std::move(modal)), show_modal_(show_modal) { - selector_ = *show_modal_; Add(Container::Tab({main_, modal_}, &selector_)); } @@ -44,7 +43,7 @@ Component Modal(Component main, Component modal, const bool* show_modal) { Component main_; Component modal_; const bool* show_modal_; - int selector_ = 0; + int selector_ = *show_modal_; }; return Make(main, modal, show_modal); } diff --git a/src/ftxui/component/radiobox.cpp b/src/ftxui/component/radiobox.cpp index 298518d..41da88b 100644 --- a/src/ftxui/component/radiobox.cpp +++ b/src/ftxui/component/radiobox.cpp @@ -28,7 +28,6 @@ class RadioboxBase : public ComponentBase { int* selected, Ref option) : entries_(entries), selected_(selected), option_(std::move(option)) { - hovered_ = *selected_; } private: @@ -175,7 +174,7 @@ class RadioboxBase : public ComponentBase { ConstStringListRef entries_; int* selected_; - int hovered_; + int hovered_ = *selected_; std::vector boxes_; Box box_; Ref option_; diff --git a/src/ftxui/dom/separator.cpp b/src/ftxui/dom/separator.cpp index 7a10dcb..8655fb7 100644 --- a/src/ftxui/dom/separator.cpp +++ b/src/ftxui/dom/separator.cpp @@ -13,8 +13,6 @@ namespace ftxui { namespace { -using ftxui::Screen; - using Charset = std::array; // NOLINT using Charsets = std::array; // NOLINT // NOLINTNEXTLINE diff --git a/src/ftxui/screen/color.cpp b/src/ftxui/screen/color.cpp index 18be388..d8b3cd0 100644 --- a/src/ftxui/screen/color.cpp +++ b/src/ftxui/screen/color.cpp @@ -132,7 +132,7 @@ Color::Color(uint8_t red, uint8_t green, uint8_t blue) /// @ingroup screen // static Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) { - return Color(red, green, blue); + return {red, green, blue}; } /// @brief Build a Color from its HSV representation. @@ -145,7 +145,7 @@ Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) { // static Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) { if (s == 0) { - return Color(v, v, v); + return {0,0,0}; } uint8_t region = h / 43; // NOLINT @@ -164,8 +164,7 @@ Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) { case 5: return Color(v,p,q); // NOLINT } // NOLINT // clang-format on - - return Color(0, 0, 0); + return {0, 0, 0}; } // static @@ -236,7 +235,7 @@ Color operator""_rgb(unsigned long long int combined) { auto const red = static_cast(combined >> 16U); auto const green = static_cast(combined >> 8U); auto const blue = static_cast(combined); - return Color(red, green, blue); + return {red, green, blue}; } } // namespace literals diff --git a/src/ftxui/screen/screen.cpp b/src/ftxui/screen/screen.cpp index 61be597..dc30d51 100644 --- a/src/ftxui/screen/screen.cpp +++ b/src/ftxui/screen/screen.cpp @@ -378,13 +378,13 @@ Dimensions Dimension::Full() { // static /// Create a screen with the given dimension along the x-axis and y-axis. Screen Screen::Create(Dimensions width, Dimensions height) { - return Screen(width.dimx, height.dimy); + return {width.dimx, height.dimy}; } // static /// Create a screen with the given dimension. Screen Screen::Create(Dimensions dimension) { - return Screen(dimension.dimx, dimension.dimy); + return {dimension.dimx, dimension.dimy}; } Screen::Screen(int dimx, int dimy)