Skip to content

Commit 4baac83

Browse files
committed
Apply clang-tidy fixes
Fix .pre-commit-config.yaml clang-tidy hook arguments Add checks to .clang-tidy: - bugprone-use-after-move - modernize-deprecated-headers - performance-move-const-arg - readability-identifier-naming - readability-operators-representation
1 parent a7e42f7 commit 4baac83

7 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎.clang-tidy‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
Checks:
22
- -*
3+
- bugprone-use-after-move
34
- cppcoreguidelines-pro-type-member-init
5+
- modernize-deprecated-headers
46
- modernize-redundant-void-arg
57
- modernize-use-bool-literals
68
- modernize-use-default-member-init
79
- modernize-use-nullptr
10+
- performance-move-const-arg
811
- readability-braces-around-statements
12+
- readability-identifier-naming
13+
- readability-operators-representation
914
- readability-redundant-member-init
10-
HeaderFileExtensions: ['', h, hh, hpp, hxx, inc]
15+
HeaderFileExtensions: ["", h, hh, hpp, hxx, inc]
1116
ImplementationFileExtensions: [c, cc, cpp, cxx]
1217
HeaderFilterRegex: (extension/src/openvic-extension)/
1318
FormatStyle: file
1419
CheckOptions:
1520
cppcoreguidelines-pro-type-member-init.IgnoreArrays: true
1621
cppcoreguidelines-pro-type-member-init.UseAssignment: true
22+
modernize-deprecated-headers.CheckHeaderFile: true
1723
modernize-use-bool-literals.IgnoreMacros: false
1824
modernize-use-default-member-init.IgnoreMacros: false
19-
modernize-use-default-member-init.UseAssignment: true
25+
modernize-use-default-member-init.UseAssignment: true
26+
readability-identifier-naming.ParameterCase: lower_case
27+
readability-operators-representation.BinaryOperators: "&&;&=;&;|;~;!;!=;||;|=;^;^="
28+
readability-operators-representation.OverloadedOperators: "&&;&=;&;|;~;!;!=;||;|=;^;^="

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ repos:
2323
--fix,
2424
--quiet,
2525
--use-color,
26-
-p=compile_commands.json,
26+
-p=out/build,
2727
-extra-arg=-Wno-unknown-warning-option,
28-
-checks=-modernize-use-bool-literals,
2928
]
3029
types_or: [text]
3130
additional_dependencies: [clang-tidy==22.1.8]

‎src/openvic-simulation/economy/production/FactoryProducer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ FactoryProducer::FactoryProducer(
3838
days_without_input { new_days_without_input },
3939
hiring_priority { new_hiring_priority },
4040
profit_history_current { new_profit_history_current },
41-
daily_profit_history { std::move(new_daily_profit_history) } {}
41+
daily_profit_history { new_daily_profit_history } {}
4242

4343
FactoryProducer::FactoryProducer(ProductionType const& new_production_type, fixed_point_t new_size_multiplier)
4444
: FactoryProducer { new_production_type, new_size_multiplier, 0, 0, 0, {}, {}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {} } {}

‎src/openvic-simulation/politics/BaseIssue.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ BaseIssue::BaseIssue(
1111
modifier_type_t new_type
1212
) : Modifier { new_identifier, std::move(new_values), new_type },
1313
HasColour { new_colour, false },
14-
rules { std::move(new_rules) },
14+
rules { new_rules },
1515
is_jingoism { new_is_jingoism } {}

‎src/openvic-simulation/research/Technology.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Technology::Technology(
3535
cost { new_cost },
3636
index_in_area { new_index_in_area },
3737
unciv_military { new_unciv_military },
38-
unit_variant { std::move(new_unit_variant) },
38+
unit_variant { new_unit_variant },
3939
activated_units { std::move(new_activated_units) },
4040
activated_buildings { std::move(new_activated_buildings) },
4141
ai_chance { std::move(new_ai_chance) } {}

‎tests/src/core/error/ErrorSet.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TEST_CASE("ErrorSet Constructor methods", "[ErrorSet][ErrorSet-constructor]") {
3030
CHECK(set_4[Error::BUG]);
3131
CHECK_FALSE(set_4[Error::FAILED]);
3232

33-
ErrorSet set_5 = std::move(set_4);
33+
ErrorSet set_5 = set_4;
3434

3535
CHECK(set_5.any());
3636
CHECK(set_5[Error::BUG]);

‎tests/src/ecs/MultiSystemMixedStage.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ ECS_SYSTEM(MmsWriteDSerial)
8282
namespace {
8383
// Common fixture: N entities each carrying Seed + all four writable components.
8484
// Returns the created entity ids in insertion order.
85-
std::vector<EntityID> seed_world(World& world, std::size_t N) {
85+
std::vector<EntityID> seed_world(World& world, std::size_t n) {
8686
std::vector<EntityID> ids;
87-
ids.reserve(N);
88-
for (std::size_t i = 0; i < N; ++i) {
87+
ids.reserve(n);
88+
for (std::size_t i = 0; i < n; ++i) {
8989
ids.push_back(world.create_entity(
9090
MmsSeed { static_cast<int64_t>(i + 1) },
9191
MmsA {}, MmsB {}, MmsC {}, MmsD {}
@@ -214,10 +214,10 @@ TEST_CASE("Mixed stage with 2 SystemThreaded + 2 plain System<> all correct",
214214
// ============================================================================
215215

216216
namespace {
217-
int64_t run_mixed_and_digest(uint32_t worker_count, std::size_t N, int ticks) {
217+
int64_t run_mixed_and_digest(uint32_t worker_count, std::size_t n, int ticks) {
218218
World world;
219219
world.set_ecs_worker_count(worker_count);
220-
std::vector<EntityID> ids = seed_world(world, N);
220+
std::vector<EntityID> ids = seed_world(world, n);
221221

222222
world.register_system<MmsWriteAThreaded>();
223223
world.register_system<MmsWriteBThreaded>();

0 commit comments

Comments
 (0)