Skip to content

Commit 3fbc72e

Browse files
authored
refactor: Update to the latest version of yscope-dev-utils:
- Update taskfiles to use the latest yscope-dev-utils tasks. - Update lint tools to use the latest yscope-dev-utils lint configs, and fix violations.
1 parent d3fc980 commit 3fbc72e

File tree

11 files changed

+83
-119
lines changed

11 files changed

+83
-119
lines changed

lint-requirements.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# Lock to v19.x until we can upgrade our code to fix new v20 issues.
2-
clang-format~=19.1
3-
# Lock to v19.x until we can upgrade our code to fix new v20 issues.
4-
clang-tidy~=19.1
1+
clang-format>=20.1.0
2+
clang-tidy>=19.1.0
53
colorama>=0.4.6
64
gersemi>=0.16.2
75
yamllint>=1.35.1

src/ystdlib/containers/test/test_Array.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,36 +75,36 @@ void test_list_initialization_in_function_call(
7575

7676
namespace ystdlib::containers::test {
7777
TEST_CASE("test_array_empty", "[containers][Array]") {
78-
Array<int> arr(0);
78+
Array<size_t> arr(0);
7979
REQUIRE(arr.empty());
8080
// NOLINTNEXTLINE(readability-container-size-empty)
8181
REQUIRE((0 == arr.size()));
8282
REQUIRE((arr.begin() == arr.end()));
8383
}
8484

8585
TEST_CASE("test_array_reference", "[containers][Array]") {
86-
Array<int> arr(cBufferSize);
87-
for (int idx{0}; idx < cBufferSize; ++idx) {
86+
Array<size_t> arr(cBufferSize);
87+
for (size_t idx{0}; idx < cBufferSize; ++idx) {
8888
arr.at(idx) = idx;
8989
}
9090
auto const& arr_const_ref = arr;
9191
REQUIRE(std::ranges::equal(arr, arr_const_ref));
9292
}
9393

9494
TEST_CASE("test_array_ranged_copy", "[containers][Array]") {
95-
std::vector<int> vec;
96-
for (int idx{0}; idx < cBufferSize; ++idx) {
95+
std::vector<size_t> vec;
96+
for (size_t idx{0}; idx < cBufferSize; ++idx) {
9797
vec.push_back(idx);
9898
}
99-
Array<int> arr(cBufferSize);
99+
Array<size_t> arr(cBufferSize);
100100
std::ranges::copy(vec, arr.begin());
101101
REQUIRE(std::ranges::equal(vec, arr));
102102
}
103103

104104
TEST_CASE("test_array_movable", "[containers][Array]") {
105-
Array<int> arr(cBufferSize);
106-
Array<int> reference_array(cBufferSize);
107-
for (int idx{0}; idx < cBufferSize; ++idx) {
105+
Array<size_t> arr(cBufferSize);
106+
Array<size_t> reference_array(cBufferSize);
107+
for (size_t idx{0}; idx < cBufferSize; ++idx) {
108108
arr.at(idx) = idx;
109109
reference_array.at(idx) = idx;
110110
}
@@ -113,7 +113,7 @@ TEST_CASE("test_array_movable", "[containers][Array]") {
113113
}
114114

115115
TEST_CASE("test_array_illegal_access", "[containers][Array]") {
116-
Array<int> arr(cBufferSize);
116+
Array<size_t> arr(cBufferSize);
117117
REQUIRE_THROWS_AS(arr.at(-1), std::out_of_range);
118118
REQUIRE_THROWS_AS(arr.at(cBufferSize), std::out_of_range);
119119
}

src/ystdlib/error_handling/ErrorCode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ErrorCode {
8787
/**
8888
* @return The reference to the singleton of the corresponded error category.
8989
*/
90-
[[nodiscard]] constexpr static auto get_category() -> ErrorCategory<ErrorCodeEnum> const& {
90+
[[nodiscard]] static constexpr auto get_category() -> ErrorCategory<ErrorCodeEnum> const& {
9191
return cCategory;
9292
}
9393

src/ystdlib/error_handling/test/test_Result.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ TEST_CASE("test_result_unique_ptr", "[error_handling][Result]") {
106106

107107
auto const result_has_error{cUniquePtrFunc(true)};
108108
REQUIRE(result_has_error.has_error());
109-
REQUIRE(AlwaysSuccessErrorCode{AlwaysSuccessErrorCodeEnum::Success} == result_has_error.error()
110-
);
109+
REQUIRE(AlwaysSuccessErrorCode{AlwaysSuccessErrorCodeEnum::Success}
110+
== result_has_error.error());
111111
}
112112

113113
TEST_CASE("test_result_unique_ptr_in_main", "[error_handling][Result]") {

taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ includes:
44
build: "./taskfiles/build.yaml"
55
deps: "./taskfiles/deps.yaml"
66
lint: "./taskfiles/lint.yaml"
7-
utils: "tools/yscope-dev-utils/taskfiles/utils.yaml"
7+
utils: "tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
88

99
vars:
1010
G_BUILD_DIR: "{{.ROOT_DIR}}/build"

taskfiles/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tasks:
1010
deps:
1111
- "init"
1212
cmds:
13-
- task: ":utils:cmake-build"
13+
- task: ":utils:cmake:build"
1414
vars:
1515
BUILD_DIR: "{{.G_BUILD_DIR}}"
1616

@@ -21,7 +21,7 @@ tasks:
2121
deps:
2222
- "init"
2323
cmds:
24-
- task: ":utils:cmake-build"
24+
- task: ":utils:cmake:build"
2525
vars:
2626
BUILD_DIR: "{{.G_BUILD_DIR}}"
2727
TARGETS:
@@ -49,7 +49,7 @@ tasks:
4949
clean:
5050
desc: "Removes all built artifacts."
5151
deps:
52-
- task: ":utils:cmake-clean"
52+
- task: ":utils:cmake:clean"
5353
vars:
5454
BUILD_DIR: "{{.G_BUILD_DIR}}"
5555

@@ -59,7 +59,7 @@ tasks:
5959
- ":deps:install-all"
6060
run: "once"
6161
cmds:
62-
- task: ":utils:cmake-generate"
62+
- task: ":utils:cmake:generate"
6363
vars:
6464
BUILD_DIR: "{{.G_BUILD_DIR}}"
6565
SOURCE_DIR: "{{.ROOT_DIR}}"

taskfiles/deps.yaml

Lines changed: 27 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,98 +13,62 @@ tasks:
1313
desc: "Install all dependencies required by ystdlib-cpp."
1414
run: "once"
1515
cmds:
16-
- task: "install-all-init"
17-
- task: "install-all-run"
18-
- task: "install-all-finish"
19-
20-
install-all-init:
21-
internal: true
22-
cmds:
23-
- "rm -rf {{.G_DEPS_CMAKE_SETTINGS_DIR}}"
24-
- "mkdir -p {{.G_DEPS_CMAKE_SETTINGS_DIR}}"
16+
- "rm -rf '{{.G_DEPS_CMAKE_SETTINGS_DIR}}'"
17+
- "mkdir -p '{{.G_DEPS_CMAKE_SETTINGS_DIR}}'"
18+
- task: ":utils:cmake:install-deps-and-generate-settings"
19+
vars:
20+
CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
21+
CMAKE_SETTINGS_FILE: "{{.G_DEPS_CMAKE_SETTINGS_FILE}}"
22+
DEP_TASK: "deps:install-all-parallel"
2523

26-
install-all-run:
24+
install-all-parallel:
2725
internal: true
2826
deps:
2927
- "install-Catch2"
3028
- "install-outcome"
3129

32-
install-all-finish:
33-
internal: true
34-
cmds:
35-
- >-
36-
for file in {{.G_DEPS_CMAKE_SETTINGS_DIR}}/*.cmake; do
37-
if [ "$file" != "{{.G_DEPS_CMAKE_SETTINGS_FILE}}" ]; then
38-
echo "include(\"$file\")" >> "{{.G_DEPS_CMAKE_SETTINGS_FILE}}";
39-
fi
40-
done
41-
42-
add-package-root-to-cmake-settings:
43-
internal: true
44-
requires:
45-
vars:
46-
- "NAME"
47-
- "INSTALL_PREFIX"
48-
cmds:
49-
- >-
50-
echo "set(
51-
{{.NAME}}_ROOT
52-
\"{{.INSTALL_PREFIX}}\"
53-
CACHE PATH
54-
\"Path to {{.NAME}} settings\"
55-
)" >> "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/{{.NAME}}.cmake"
56-
5730
install-Catch2:
5831
internal: true
5932
run: "once"
6033
cmds:
61-
- task: ":utils:cmake-install-remote-tar"
34+
- task: ":utils:cmake:install-remote-tar"
6235
vars:
63-
NAME: "{{.G_CATCH2_LIB_NAME}}"
36+
CMAKE_PACKAGE_NAME: "{{.G_CATCH2_LIB_NAME}}"
37+
CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
38+
TAR_SHA256: "1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087"
39+
TAR_URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz"
6440
WORK_DIR: "{{.G_CATCH2_WORK_DIR}}"
65-
FILE_SHA256: "1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087"
66-
URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz"
67-
- task: "add-package-root-to-cmake-settings"
68-
vars:
69-
NAME: "{{.G_CATCH2_LIB_NAME}}"
70-
INSTALL_PREFIX: "{{.G_CATCH2_WORK_DIR}}/{{.G_CATCH2_LIB_NAME}}-install"
7141

7242
install-outcome:
7343
internal: true
7444
run: "once"
7545
deps:
7646
- "install-quickcpplib"
7747
cmds:
78-
- task: ":utils:cmake-install-remote-tar"
48+
- task: ":utils:cmake:install-remote-tar"
7949
vars:
80-
NAME: "{{.G_OUTCOME_LIB_NAME}}"
81-
WORK_DIR: "{{.G_OUTCOME_WORK_DIR}}"
82-
FILE_SHA256: "0382248cbb00806ce4b5f3ce6939797dc3b597c85fd3531614959e31ef488b39"
83-
URL: "https://github.com/ned14/outcome/archive/refs/tags/v2.2.11.tar.gz"
84-
GEN_ARGS:
50+
CMAKE_GEN_ARGS:
8551
- "-C {{.G_DEPS_CMAKE_SETTINGS_DIR}}/{{.G_QUICKCPPLIB_LIB_NAME}}.cmake"
8652
- "-DBUILD_TESTING=OFF"
8753
- "-DCMAKE_BUILD_TYPE=Release"
8854
- "-DCMAKE_POLICY_DEFAULT_CMP0074=NEW"
89-
- task: "add-package-root-to-cmake-settings"
90-
vars:
91-
NAME: "{{.G_OUTCOME_LIB_NAME}}"
92-
INSTALL_PREFIX: "{{.G_OUTCOME_WORK_DIR}}/{{.G_OUTCOME_LIB_NAME}}-install"
55+
CMAKE_PACKAGE_NAME: "{{.G_OUTCOME_LIB_NAME}}"
56+
CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
57+
TAR_SHA256: "0382248cbb00806ce4b5f3ce6939797dc3b597c85fd3531614959e31ef488b39"
58+
TAR_URL: "https://github.com/ned14/outcome/archive/refs/tags/v2.2.11.tar.gz"
59+
WORK_DIR: "{{.G_OUTCOME_WORK_DIR}}"
9360

9461
install-quickcpplib:
9562
internal: true
9663
run: "once"
9764
cmds:
98-
- task: ":utils:cmake-install-remote-tar"
65+
- task: ":utils:cmake:install-remote-tar"
9966
vars:
100-
NAME: "{{.G_QUICKCPPLIB_LIB_NAME}}"
101-
WORK_DIR: "{{.G_QUICKCPPLIB_WORK_DIR}}"
102-
FILE_SHA256: "5d4c9b2d6fa177d3fb14f3fe3086867e43b44f4a7a944eb10ee4616b2b0f3c05"
103-
URL: "https://github.com/ned14/quickcpplib/archive/f3e452e.tar.gz"
104-
GEN_ARGS:
67+
CMAKE_GEN_ARGS:
10568
- "-DBUILD_TESTING=OFF"
10669
- "-DCMAKE_BUILD_TYPE=Release"
107-
- task: "add-package-root-to-cmake-settings"
108-
vars:
109-
NAME: "{{.G_QUICKCPPLIB_LIB_NAME}}"
110-
INSTALL_PREFIX: "{{.G_QUICKCPPLIB_WORK_DIR}}/{{.G_QUICKCPPLIB_LIB_NAME}}-install"
70+
CMAKE_PACKAGE_NAME: "{{.G_QUICKCPPLIB_LIB_NAME}}"
71+
CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
72+
TAR_SHA256: "5d4c9b2d6fa177d3fb14f3fe3086867e43b44f4a7a944eb10ee4616b2b0f3c05"
73+
TAR_URL: "https://github.com/ned14/quickcpplib/archive/f3e452e.tar.gz"
74+
WORK_DIR: "{{.G_QUICKCPPLIB_WORK_DIR}}"

taskfiles/lint-cpp.yaml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: "3"
22

3+
vars:
4+
G_LINT_CLANG_TIDY_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy"
5+
36
tasks:
47
cpp-check:
58
desc: "Runs the C++ linters."
@@ -26,11 +29,11 @@ tasks:
2629
- "cpp-configs"
2730
- "venv"
2831
cmds:
29-
- task: ":utils:clang-format"
32+
- task: ":utils:cpp-lint:clang-format"
3033
vars:
31-
FLAGS: "--dry-run"
32-
SRC_PATHS:
33-
ref: ".G_LINT_CPP_DIRS"
34+
FLAGS: ["--dry-run"]
35+
INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp"]
36+
ROOT_PATHS: ["{{.G_CPP_SRC_DIR}}"]
3437
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
3538

3639
cpp-format-fix:
@@ -40,11 +43,11 @@ tasks:
4043
- "cpp-configs"
4144
- "venv"
4245
cmds:
43-
- task: ":utils:clang-format"
46+
- task: ":utils:cpp-lint:clang-format"
4447
vars:
45-
FLAGS: "-i"
46-
SRC_PATHS:
47-
ref: ".G_LINT_CPP_DIRS"
48+
FLAGS: ["-i"]
49+
INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp"]
50+
ROOT_PATHS: ["{{.G_CPP_SRC_DIR}}"]
4851
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
4952

5053
cpp-static-check:
@@ -55,38 +58,29 @@ tasks:
5558
aliases:
5659
- "cpp-static-fix"
5760
desc: "Runs the C++ static analyzers. Only checks for warnings and violations."
58-
sources:
59-
- "{{.G_CMAKE_CACHE}}"
60-
- "{{.G_COMPILE_COMMANDS_DB}}"
61-
- "{{.G_LINT_VENV_CHECKSUM_FILE}}"
62-
- "{{.G_CPP_SRC_DIR}}/**/*.cpp"
63-
- "{{.G_CPP_SRC_DIR}}/**/*.h"
64-
- "{{.G_CPP_SRC_DIR}}/**/*.hpp"
65-
- "{{.ROOT_DIR}}/.clang-tidy"
66-
- "{{.TASKFILE}}"
6761
deps:
6862
- ":build:init"
6963
- "cpp-configs"
7064
- "venv"
7165
cmds:
72-
- task: ":utils:clang-tidy"
66+
- task: ":utils:cpp-lint:clang-tidy-find"
7367
vars:
74-
FLAGS: >-
75-
--config-file "{{.ROOT_DIR}}/.clang-tidy"
76-
-p "{{.G_COMPILE_COMMANDS_DB}}"
77-
SRC_PATHS:
78-
ref: ".G_LINT_CPP_DIRS"
68+
FLAGS:
69+
- "--config-file '{{.ROOT_DIR}}/.clang-tidy'"
70+
- "-p '{{.G_COMPILE_COMMANDS_DB}}'"
71+
OUTPUT_DIR: "{{.G_LINT_CLANG_TIDY_DIR}}"
72+
ROOT_PATHS: ["{{.G_CPP_SRC_DIR}}"]
7973
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
8074

8175
cpp-configs:
8276
internal: true
8377
sources:
84-
- "{{.ROOT_DIR}}/tools/yscope-dev-utils/lint-configs/.clang-format"
85-
- "{{.ROOT_DIR}}/tools/yscope-dev-utils/lint-configs/.clang-tidy"
78+
- "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/.clang-format"
79+
- "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/.clang-tidy"
8680
- "{{.TASKFILE}}"
8781
generates:
8882
- "{{.ROOT_DIR}}/.clang-format"
8983
- "{{.ROOT_DIR}}/.clang-tidy"
9084
dir: "{{.ROOT_DIR}}"
9185
cmds:
92-
- "tools/yscope-dev-utils/lint-configs/symlink-cpp-lint-configs.sh"
86+
- "tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh"

taskfiles/lint-venv.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ tasks:
1515
run: "once"
1616
deps:
1717
- ":init"
18-
- task: ":utils:validate-checksum"
18+
- task: ":utils:checksum:validate"
1919
vars:
2020
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
2121
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
2222
cmds:
23-
- task: ":utils:create-venv"
23+
- task: ":utils:misc:create-venv"
2424
vars:
2525
LABEL: "lint"
2626
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
2727
REQUIREMENTS_FILE: "{{.ROOT_DIR}}/lint-requirements.txt"
2828
# This command must be last
29-
- task: ":utils:compute-checksum"
29+
- task: ":utils:checksum:compute"
3030
vars:
3131
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
3232
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]

taskfiles/lint-yaml.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,24 @@ tasks:
1313
- "{{.TASKFILE}}"
1414
- exclude: "{{.ROOT_DIR}}/**/build/*"
1515
- exclude: "{{.ROOT_DIR}}/**/tools/*"
16+
17+
# Exclude CMake build directories generated by CLion
18+
- exclude: "{{.ROOT_DIR}}/**/cmake-build-*"
1619
dir: "{{.ROOT_DIR}}"
1720
deps:
1821
- "venv"
1922
cmds:
2023
- |-
2124
. "{{.G_LINT_VENV_DIR}}/bin/activate"
2225
find . \
23-
\( -path '**/build' -o -path '**/tools' \) -prune -o \
26+
\( \
27+
-path '**/build' \
28+
-o -path '**/tools' \
29+
-o -path '**/cmake-build-*' \
30+
\) -prune -o \
2431
\( -iname "*.yaml" -o -iname "*.yml" \) \
2532
-print0 | \
26-
xargs -0 yamllint \
27-
--config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \
28-
--strict
33+
xargs -0 \
34+
yamllint \
35+
--config-file "tools/yscope-dev-utils/exports/lint-configs/.yamllint.yml" \
36+
--strict

0 commit comments

Comments
 (0)