Skip to content

Commit 28473f6

Browse files
committed
Fixes as needed for latest clang-tidy
1 parent 883b411 commit 28473f6

5 files changed

Lines changed: 42 additions & 30 deletions

File tree

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Checks: "*,
1313
-readability-avoid-const-params-in-decls,
1414
-cppcoreguidelines-non-private-member-variables-in-classes,
1515
-misc-non-private-member-variables-in-classes,
16+
-misc-no-recursion,
17+
-misc-use-anonymous-namespace,
18+
-misc-use-internal-linkage
1619
"
1720
WarningsAsErrors: ''
1821
HeaderFilterRegex: ''

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.21)
66

77
# Only set the cxx_standard if it is not set by someone else
88
if (NOT DEFINED CMAKE_CXX_STANDARD)
9-
set(CMAKE_CXX_STANDARD 20)
9+
set(CMAKE_CXX_STANDARD 23)
1010
endif()
1111

1212
# strongly encouraged to enable this globally to avoid conflicts between

cmake/CPM.cmake

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
set(CPM_DOWNLOAD_VERSION 0.38.1)
1+
# SPDX-License-Identifier: MIT
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
4+
5+
set(CPM_DOWNLOAD_VERSION 0.40.8)
6+
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")
27

38
if(CPM_SOURCE_CACHE)
49
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
@@ -11,23 +16,9 @@ endif()
1116
# Expand relative path. This is important if the provided path contains a tilde (~)
1217
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
1318

14-
function(download_cpm)
15-
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16-
file(DOWNLOAD
17-
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18-
${CPM_DOWNLOAD_LOCATION}
19-
)
20-
endfunction()
21-
22-
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23-
download_cpm()
24-
else()
25-
# resume download if it previously failed
26-
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27-
if("${check}" STREQUAL "")
28-
download_cpm()
29-
endif()
30-
unset(check)
31-
endif()
19+
file(DOWNLOAD
20+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
21+
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
22+
)
3223

3324
include(${CPM_DOWNLOAD_LOCATION})

fuzz_test/fuzz_tester.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#include <fmt/format.h>
1+
#include <cstdint>
2+
#include <cstddef>
3+
#include <fmt/base.h>
24
#include <iterator>
3-
#include <utility>
45

56
[[nodiscard]] auto sum_values(const uint8_t *Data, size_t Size)
67
{

src/ftxui_sample/main.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
#include <array>
2+
#include <cstddef>
3+
#include <ftxui/dom/elements.hpp>
4+
#include <cstdint>
5+
#include <ftxui/dom/node.hpp>
6+
#include <ftxui/screen/screen.hpp>
7+
#include <chrono>
8+
#include <atomic>
9+
#include <fmt/format.h>
10+
#include <fmt/base.h>
11+
#include <cstdlib>
12+
#include <exception>
213
#include <functional>
3-
#include <iostream>
414
#include <optional>
515

616
#include <random>
717

818
#include <CLI/CLI.hpp>
9-
#include <ftxui/component/captured_mouse.hpp>// for ftxui
1019
#include <ftxui/component/component.hpp>// for Slider
1120
#include <ftxui/component/screen_interactive.hpp>// for ScreenInteractive
1221
#include <spdlog/spdlog.h>
@@ -17,6 +26,10 @@
1726
// configuration step. It creates a namespace called `myproject`. You can modify
1827
// the source template at `configured_files/config.hpp.in`.
1928
#include <internal_use_only/config.hpp>
29+
#include <string>
30+
#include <vector>
31+
#include <utility>
32+
#include <thread>
2033

2134
template<std::size_t Width, std::size_t Height> struct GameBoard
2235
{
@@ -89,7 +102,7 @@ template<std::size_t Width, std::size_t Height> struct GameBoard
89102
}
90103
};
91104

92-
105+
namespace {
93106
void consequence_game()
94107
{
95108
auto screen = ftxui::ScreenInteractive::TerminalOutput();
@@ -162,6 +175,7 @@ void consequence_game()
162175

163176
screen.Loop(renderer);
164177
}
178+
}
165179

166180
struct Color
167181
{
@@ -177,13 +191,12 @@ struct Bitmap : ftxui::Node
177191
: width_(width), height_(height)
178192
{}
179193

180-
Color &at(std::size_t cur_x, std::size_t cur_y) { return pixels.at(width_ * cur_y + cur_x); }
194+
Color &at(std::size_t cur_x, std::size_t cur_y) { return pixels.at((width_ * cur_y) + cur_x); }
181195

182196
void ComputeRequirement() override
183197
{
184-
requirement_ = ftxui::Requirement{
185-
.min_x = static_cast<int>(width_), .min_y = static_cast<int>(height_ / 2), .selected_box{ 0, 0, 0, 0 }
186-
};
198+
requirement_.min_x = static_cast<int>(width_);
199+
requirement_.min_y = static_cast<int>(height_ / 2);
187200
}
188201

189202
void Render(ftxui::Screen &screen) override
@@ -193,7 +206,7 @@ struct Bitmap : ftxui::Node
193206
auto &pixel = screen.PixelAt(box_.x_min + static_cast<int>(cur_x), box_.y_min + static_cast<int>(cur_y));
194207
pixel.character = "";
195208
const auto &top_color = at(cur_x, cur_y * 2);
196-
const auto &bottom_color = at(cur_x, cur_y * 2 + 1);
209+
const auto &bottom_color = at(cur_x, (cur_y * 2) + 1);
197210
pixel.background_color = ftxui::Color{ top_color.R.get(), top_color.G.get(), top_color.B.get() };
198211
pixel.foreground_color = ftxui::Color{ bottom_color.R.get(), bottom_color.G.get(), bottom_color.B.get() };
199212
}
@@ -213,6 +226,7 @@ struct Bitmap : ftxui::Node
213226
std::vector<Color> pixels = std::vector<Color>(width_ * height_, Color{});
214227
};
215228

229+
namespace {
216230
void game_iteration_canvas()
217231
{
218232
// this should probably have a `bitmap` helper function that does what cur_you expect
@@ -257,6 +271,8 @@ void game_iteration_canvas()
257271
case 2:
258272
small_bm_pixel.B += 11;// NOLINT Magic Number
259273
break;
274+
default: // literally impossible
275+
std::unreachable();
260276
}
261277

262278

@@ -308,6 +324,7 @@ void game_iteration_canvas()
308324
refresh_ui_continue = false;
309325
refresh_ui.join();
310326
}
327+
}
311328

312329
// NOLINTNEXTLINE(bugprone-exception-escape)
313330
int main(int argc, const char **argv)

0 commit comments

Comments
 (0)