From 5c58e894a540311f0abecc40c8c3399cf752d8d3 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Fri, 17 Jul 2026 23:48:07 -0400 Subject: [PATCH] Update pre-commit hooks Update ruff-check/ruff-format to v0.15.22 Update mypy to v2.3.0 Update typos to v1.48.0 Update clang-tidy dependency to 22.1.8 Apply clang-tidy fixes --- .pre-commit-config.yaml | 20 +++++++++++++------ pyproject.toml | 6 ++++++ .../economy/production/ArtisanalProducer.cpp | 2 +- src/openvic-simulation/ecs/CommandBuffer.hpp | 4 ++-- .../ecs/SystemScheduler.cpp | 4 ++-- src/openvic-simulation/scripts/Condition.cpp | 2 +- .../ecs/SystemSchedulerSingletonWrites.cpp | 8 ++++++-- tests/src/ecs/SystemScheduler_Conflicts.cpp | 16 +++++++++++---- tests/src/ecs/SystemScheduler_DAG.cpp | 18 +++++++++++++---- 9 files changed, 58 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b378dc847..17ea48587 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,14 +18,22 @@ repos: hooks: - id: clang-tidy files: \.(c|h|cpp|hpp)$ - args: [--fix, --quiet, --use-color] + args: + [ + --fix, + --quiet, + --use-color, + -p=compile_commands.json, + -extra-arg=-Wno-unknown-warning-option, + -checks=-modernize-use-bool-literals, + ] types_or: [text] - additional_dependencies: [clang-tidy==19.1.0] + additional_dependencies: [clang-tidy==22.1.8] require_serial: true stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy` - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.1 + rev: v0.15.22 hooks: - id: ruff-check args: [--fix] @@ -36,17 +44,17 @@ repos: types_or: [text] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v2.3.0 hooks: - id: mypy files: \.py$ types_or: [text] - repo: https://github.com/crate-ci/typos - rev: v1.30.2 + rev: v1.48.0 hooks: - id: typos # exclude: | # (?x)^( # ) - additional_dependencies: [tomli] \ No newline at end of file + additional_dependencies: [tomli] diff --git a/pyproject.toml b/pyproject.toml index ffc6baf53..7e60f8d31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,3 +35,9 @@ default.extend-ignore-re = [ "(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on", # Multiline check disable with // spellchecker:off // spellchecker:on (can also use #) "(?s)(/\\*)\\s*spellchecker:off.*?\\s*spellchecker:on\\s*(\\*/)", # Multiline check disable with /* spellchecker:off ... spellchecker:on */ ] + +[tool.typos.type.skip_names] +extend-glob = ["AUTHORS.md", "COPYRIGHT", "CODE_OF_CONDUCT.md", "credits.csv"] + +[tool.typos.type.skip_names.extend-identifiers] +Catylist = "Catylist" diff --git a/src/openvic-simulation/economy/production/ArtisanalProducer.cpp b/src/openvic-simulation/economy/production/ArtisanalProducer.cpp index c2c441f3f..33eb06de4 100644 --- a/src/openvic-simulation/economy/production/ArtisanalProducer.cpp +++ b/src/openvic-simulation/economy/production/ArtisanalProducer.cpp @@ -190,7 +190,7 @@ void ArtisanalProducer::artisan_tick_handler::allocate_money_for_inputs( return; } - //Figure out the optimal amount of goods to buy based on their price, stockpiled quantiy & demand + //Figure out the optimal amount of goods to buy based on their price, stockpiled quantity & demand fixed_point_t max_possible_satisfaction_numerator= 1, max_possible_satisfaction_denominator= 1; diff --git a/src/openvic-simulation/ecs/CommandBuffer.hpp b/src/openvic-simulation/ecs/CommandBuffer.hpp index e15824620..a84199ae4 100644 --- a/src/openvic-simulation/ecs/CommandBuffer.hpp +++ b/src/openvic-simulation/ecs/CommandBuffer.hpp @@ -314,9 +314,9 @@ namespace OpenVic::ecs { }; struct AddPayload { - component_type_id_t id; + component_type_id_t id = 0UL; PayloadSlot value; // .vtable always set (even for tag — size==0); .data null for tag/default - bool is_default; // true when add_component() with no value + bool is_default = false; // true when add_component() with no value }; struct Op { diff --git a/src/openvic-simulation/ecs/SystemScheduler.cpp b/src/openvic-simulation/ecs/SystemScheduler.cpp index 01ea4dd5c..5c0fdacc9 100644 --- a/src/openvic-simulation/ecs/SystemScheduler.cpp +++ b/src/openvic-simulation/ecs/SystemScheduler.cpp @@ -525,7 +525,7 @@ void SystemScheduler::run( (*cbs)[i].set_parallel_mode(true); } for (std::size_t i = 0; i < chunks.size(); ++i) { - WorkItem item; + WorkItem item {}; item.kind = WorkKind::ThreadedChunk; item.reg_idx = reg_idx; item.archetype_idx = chunks[i].archetype_idx; @@ -540,7 +540,7 @@ void SystemScheduler::run( // Plain System<> (or a SystemThreaded with no entry points — shouldn't // happen post-Phase-0). One whole-tick work item; dispatch_serial // inside tick_all does not depend on current_system_registration_. - WorkItem item; + WorkItem item {}; item.kind = WorkKind::SerialWhole; item.reg_idx = reg_idx; item.archetype_idx = 0; diff --git a/src/openvic-simulation/scripts/Condition.cpp b/src/openvic-simulation/scripts/Condition.cpp index eb8ef376c..0372910a3 100644 --- a/src/openvic-simulation/scripts/Condition.cpp +++ b/src/openvic-simulation/scripts/Condition.cpp @@ -261,7 +261,7 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana ret &= add_condition("this_culture_union", IDENTIFIER, COUNTRY, NO_SCOPE, NO_IDENTIFIER, CULTURE_UNION); ret &= add_condition("total_amount_of_divisions", INTEGER, COUNTRY); ret &= add_condition("total_amount_of_ships", INTEGER, COUNTRY); - ret &= add_condition("total_defensives", INTEGER, COUNTRY); + ret &= add_condition("total_defensives", INTEGER, COUNTRY); // paradox typo ret &= add_condition("total_num_of_ports", INTEGER, COUNTRY); ret &= add_condition("total_of_ours_sunk", INTEGER, COUNTRY); ret &= add_condition("total_pops", INTEGER, COUNTRY); diff --git a/tests/src/ecs/SystemSchedulerSingletonWrites.cpp b/tests/src/ecs/SystemSchedulerSingletonWrites.cpp index f35881bea..c3154b3bb 100644 --- a/tests/src/ecs/SystemSchedulerSingletonWrites.cpp +++ b/tests/src/ecs/SystemSchedulerSingletonWrites.cpp @@ -46,7 +46,9 @@ namespace { SgwState* state = ctx.world.get_singleton(); state->acc = (state->acc * 31 + a.v) % 1000003; a.v = (a.v * 7 + 3) % 1000003; - if (g_sgw_log) g_sgw_log->push_back(1); + if (g_sgw_log) { + g_sgw_log->push_back(1); + } } }; @@ -71,7 +73,9 @@ namespace { void tick(TickContext const& ctx, SgwB& b) { SgwState const* state = ctx.world.get_singleton(); b.v = (b.v * 13 + state->acc) % 1000003; - if (g_sgw_log) g_sgw_log->push_back(2); + if (g_sgw_log) { + g_sgw_log->push_back(2); + } } }; diff --git a/tests/src/ecs/SystemScheduler_Conflicts.cpp b/tests/src/ecs/SystemScheduler_Conflicts.cpp index 61a071392..ef769f831 100644 --- a/tests/src/ecs/SystemScheduler_Conflicts.cpp +++ b/tests/src/ecs/SystemScheduler_Conflicts.cpp @@ -27,27 +27,35 @@ namespace { struct ConflictWriterA : System { void tick(TickContext const& /*ctx*/, ConflictTagX& x) { x.n += 1; - if (g_conflict_log) g_conflict_log->push_back(1); + if (g_conflict_log) { + g_conflict_log->push_back(1); + } } }; struct ConflictWriterB : System { void tick(TickContext const& /*ctx*/, ConflictTagX& x) { x.n *= 2; - if (g_conflict_log) g_conflict_log->push_back(2); + if (g_conflict_log) { + g_conflict_log->push_back(2); + } } }; // R/R is fine — should run in the same stage with no conflict edge required. struct ConflictReaderA : System { void tick(TickContext const& /*ctx*/, ConflictTagY const& /*y*/) { - if (g_conflict_log) g_conflict_log->push_back(11); + if (g_conflict_log) { + g_conflict_log->push_back(11); + } } }; struct ConflictReaderB : System { void tick(TickContext const& /*ctx*/, ConflictTagY const& /*y*/) { - if (g_conflict_log) g_conflict_log->push_back(12); + if (g_conflict_log) { + g_conflict_log->push_back(12); + } } }; } diff --git a/tests/src/ecs/SystemScheduler_DAG.cpp b/tests/src/ecs/SystemScheduler_DAG.cpp index 5aa31c986..b836c8bc7 100644 --- a/tests/src/ecs/SystemScheduler_DAG.cpp +++ b/tests/src/ecs/SystemScheduler_DAG.cpp @@ -45,7 +45,9 @@ ECS_SYSTEM(SchedDagSystemC) namespace { struct SchedDagSystemA : System { void tick(TickContext const& /*ctx*/, SchedulerTagA& /*t*/) { - if (g_scheduler_dag_log) g_scheduler_dag_log->push_back(1); + if (g_scheduler_dag_log) { + g_scheduler_dag_log->push_back(1); + } } }; @@ -57,7 +59,9 @@ namespace { }; } void tick(TickContext const& /*ctx*/, SchedulerTagB& /*t*/) { - if (g_scheduler_dag_log) g_scheduler_dag_log->push_back(2); + if (g_scheduler_dag_log) { + g_scheduler_dag_log->push_back(2); + } } }; @@ -69,7 +73,9 @@ namespace { }; } void tick(TickContext const& /*ctx*/, SchedulerTagC& /*t*/) { - if (g_scheduler_dag_log) g_scheduler_dag_log->push_back(3); + if (g_scheduler_dag_log) { + g_scheduler_dag_log->push_back(3); + } } }; } @@ -124,7 +130,11 @@ TEST_CASE("Scheduler order is identical regardless of registration order", } world.tick_systems(Date {}); - if (run == 0) log_first = log; else log_second = log; + if (run == 0) { + log_first = log; + } else { + log_second = log; + } g_scheduler_dag_log = nullptr; }