Skip to content

Commit bec9bba

Browse files
authored
Merge pull request #2389 from joto/class-suffix-t
Add suffix_t to all classes and enable naming checks in clang-tidy
2 parents 0f907bf + 24f0fcd commit bec9bba

File tree

7 files changed

+71
-49
lines changed

7 files changed

+71
-49
lines changed

.clang-tidy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,26 @@ CheckOptions:
106106
value: true
107107
- key: bugprone-empty-catch.IgnoreCatchWithKeywords
108108
value: "@todo;@fixme;exception ignored on purpose"
109+
- key: readability-identifier-naming.ClassCase
110+
value: lower_case
111+
- key: readability-identifier-naming.ClassSuffix
112+
value: _t
113+
- key: readability-identifier-naming.PrivateMemberPrefix
114+
value: m_
115+
- key: readability-identifier-naming.StructCase
116+
value: lower_case
117+
- key: readability-identifier-naming.EnumCase
118+
value: lower_case
119+
- key: readability-identifier-naming.FunctionCase
120+
value: lower_case
121+
- key: readability-identifier-naming.FunctionIgnoredRegexp
122+
value: luaX.*
123+
- key: readability-identifier-naming.VariableCase
124+
value: lower_case
125+
- key: readability-identifier-naming.ConstexprVariableCase
126+
value: UPPER_CASE
127+
- key: readability-identifier-naming.GlobalConstantCase
128+
value: UPPER_CASE
129+
- key: readability-identifier-naming.NamespaceCase
130+
value: lower_case
109131
...

src/geom-functions.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ std::size_t num_geometries(geometry_t const &geom)
6969

7070
namespace {
7171

72-
class geometry_n_visitor
72+
class geometry_n_visitor_t
7373
{
7474
public:
75-
geometry_n_visitor(geometry_t *output, std::size_t n)
75+
geometry_n_visitor_t(geometry_t *output, std::size_t n)
7676
: m_output(output), m_n(n)
7777
{}
7878

@@ -97,7 +97,7 @@ class geometry_n_visitor
9797
geometry_t *m_output;
9898
std::size_t m_n;
9999

100-
}; // class geometry_n_visitor
100+
}; // class geometry_n_visitor_t
101101

102102
} // anonymous namespace
103103

@@ -109,7 +109,7 @@ void geometry_n(geometry_t *output, geometry_t const &input, std::size_t n)
109109
return;
110110
}
111111

112-
input.visit(geometry_n_visitor{output, n - 1});
112+
input.visit(geometry_n_visitor_t{output, n - 1});
113113
output->set_srid(input.srid());
114114
}
115115

@@ -130,11 +130,11 @@ void set_to_same_type(geometry_t *output, geometry_t const &input)
130130
input.visit([&](auto in) { output->set<decltype(in)>(); });
131131
}
132132

133-
class transform_visitor
133+
class transform_visitor_t
134134
{
135135
public:
136-
explicit transform_visitor(geometry_t *output,
137-
reprojection const *reprojection)
136+
explicit transform_visitor_t(geometry_t *output,
137+
reprojection const *reprojection)
138138
: m_output(output), m_reprojection(reprojection)
139139
{}
140140

@@ -190,7 +190,7 @@ class transform_visitor
190190
auto &new_geom = m.add_geometry();
191191
set_to_same_type(&new_geom, geom);
192192
new_geom.set_srid(0);
193-
geom.visit(transform_visitor{&new_geom, m_reprojection});
193+
geom.visit(transform_visitor_t{&new_geom, m_reprojection});
194194
}
195195
}
196196

@@ -222,7 +222,7 @@ class transform_visitor
222222
geometry_t *m_output;
223223
reprojection const *m_reprojection;
224224

225-
}; // class transform_visitor
225+
}; // class transform_visitor_t
226226

227227
} // anonymous namespace
228228

@@ -233,7 +233,7 @@ void transform(geometry_t *output, geometry_t const &input,
233233

234234
set_to_same_type(output, input);
235235
output->set_srid(reprojection.target_srs());
236-
input.visit(transform_visitor{output, &reprojection});
236+
input.visit(transform_visitor_t{output, &reprojection});
237237
}
238238

239239
geometry_t transform(geometry_t const &input, reprojection const &reprojection)
@@ -251,10 +251,10 @@ namespace {
251251
* Helper class for iterating over all points except the first one in a point
252252
* list.
253253
*/
254-
class without_first
254+
class without_first_t
255255
{
256256
public:
257-
explicit without_first(point_list_t const &list) : m_list(&list) {}
257+
explicit without_first_t(point_list_t const &list) : m_list(&list) {}
258258

259259
point_list_t::const_iterator begin()
260260
{
@@ -266,7 +266,7 @@ class without_first
266266

267267
private:
268268
point_list_t const *m_list;
269-
}; // class without_first
269+
}; // class without_first_t
270270

271271
void split_linestring(linestring_t const &line, double split_at,
272272
multilinestring_t *output)
@@ -276,7 +276,7 @@ void split_linestring(linestring_t const &line, double split_at,
276276
linestring_t *out = &output->add_geometry();
277277
out->push_back(prev_pt);
278278

279-
for (auto const &this_pt : without_first(line)) {
279+
for (auto const &this_pt : without_first_t(line)) {
280280
double const delta = distance(prev_pt, this_pt);
281281

282282
// figure out if the addition of this point would take the total
@@ -428,10 +428,10 @@ double length(geometry_t const &geom)
428428

429429
namespace {
430430

431-
class split_visitor
431+
class split_visitor_t
432432
{
433433
public:
434-
split_visitor(std::vector<geometry_t> *output, int srid) noexcept
434+
split_visitor_t(std::vector<geometry_t> *output, int srid) noexcept
435435
: m_output(output), m_srid(srid)
436436
{}
437437

@@ -462,7 +462,7 @@ class split_visitor
462462
std::vector<geometry_t> *m_output;
463463
int m_srid;
464464

465-
}; // class split_visitor
465+
}; // class split_visitor_t
466466

467467
} // anonymous namespace
468468

@@ -471,7 +471,7 @@ std::vector<geometry_t> split_multi(geometry_t &&geom, bool split_multi)
471471
std::vector<geometry_t> output;
472472

473473
if (split_multi && geom.is_multi()) {
474-
visit(split_visitor{&output, geom.srid()}, std::move(geom));
474+
visit(split_visitor_t{&output, geom.srid()}, std::move(geom));
475475
} else if (!geom.is_null()) {
476476
output.push_back(std::move(geom));
477477
}

src/middle-pgsql.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ void pgsql_parse_json_tags(char const *string, osmium::memory::Buffer *buffer,
151151
/**
152152
* Helper class for parsing relation members encoded in JSON.
153153
*/
154-
class member_list_json_builder
154+
class member_list_json_builder_t
155155
{
156156
public:
157-
explicit member_list_json_builder(
157+
explicit member_list_json_builder_t(
158158
osmium::builder::RelationMemberListBuilder *builder)
159159
: m_builder(builder)
160160
{}
@@ -246,7 +246,7 @@ class member_list_json_builder
246246
ref,
247247
role
248248
} m_next_val = next_val::none;
249-
}; // class member_list_json_builder
249+
}; // class member_list_json_builder_t
250250

251251
template <typename T>
252252
void pgsql_parse_json_members(char const *string,
@@ -257,7 +257,7 @@ void pgsql_parse_json_members(char const *string,
257257
}
258258

259259
osmium::builder::RelationMemberListBuilder builder{*buffer, obuilder};
260-
member_list_json_builder parser{&builder};
260+
member_list_json_builder_t parser{&builder};
261261
nlohmann::json::sax_parse(string, &parser);
262262
}
263263

src/osmdata.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ namespace {
197197
* handles this extra processing by starting a number of threads and doing
198198
* the processing in them.
199199
*/
200-
class multithreaded_processor
200+
class multithreaded_processor_t
201201
{
202202
public:
203-
multithreaded_processor(connection_params_t const &connection_params,
204-
std::shared_ptr<middle_t> const &mid,
205-
std::shared_ptr<output_t> output,
206-
std::size_t thread_count)
203+
multithreaded_processor_t(connection_params_t const &connection_params,
204+
std::shared_ptr<middle_t> const &mid,
205+
std::shared_ptr<output_t> output,
206+
std::size_t thread_count)
207207
: m_output(std::move(output))
208208
{
209209
assert(mid);
@@ -379,8 +379,8 @@ class multithreaded_processor
379379

380380
void osmdata_t::process_dependents()
381381
{
382-
multithreaded_processor proc{m_connection_params, m_mid, m_output,
383-
m_num_procs};
382+
multithreaded_processor_t proc{m_connection_params, m_mid, m_output,
383+
m_num_procs};
384384

385385
// stage 1b processing: process parents of changed objects
386386
if (!m_ways_pending_tracker.empty() || !m_rels_pending_tracker.empty()) {

src/wkb.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ void write_collection(std::string *data, geom::collection_t const &geom,
195195
}
196196
}
197197

198-
class make_ewkb_visitor
198+
class make_ewkb_visitor_t
199199
{
200200
public:
201-
make_ewkb_visitor(uint32_t srid, bool ensure_multi) noexcept
201+
make_ewkb_visitor_t(uint32_t srid, bool ensure_multi) noexcept
202202
: m_srid(srid), m_ensure_multi(ensure_multi)
203203
{}
204204

@@ -292,7 +292,7 @@ class make_ewkb_visitor
292292
uint32_t m_srid;
293293
bool m_ensure_multi;
294294

295-
}; // class make_ewkb_visitor
295+
}; // class make_ewkb_visitor_t
296296

297297
/**
298298
* Parser for (E)WKB.
@@ -560,7 +560,7 @@ class ewkb_parser_t
560560

561561
std::string geom_to_ewkb(geom::geometry_t const &geom, bool ensure_multi)
562562
{
563-
return geom.visit(ewkb::make_ewkb_visitor{
563+
return geom.visit(ewkb::make_ewkb_visitor_t{
564564
static_cast<uint32_t>(geom.srid()), ensure_multi});
565565
}
566566

tests/test-flex-indexes.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
#include <lua.hpp>
1717

18-
class test_framework
18+
class test_framework_t
1919
{
2020
public:
21-
test_framework()
21+
test_framework_t()
2222
: m_lua_state(luaL_newstate(), [](lua_State *state) { lua_close(state); })
2323
{
2424
auto &c = database_capabilities_for_testing();
@@ -46,7 +46,7 @@ class test_framework
4646

4747
TEST_CASE("check index with single column", "[NoDB]")
4848
{
49-
test_framework const tf;
49+
test_framework_t const tf;
5050

5151
flex_table_t table{"public", "test_table", 0};
5252
table.add_column("geom", "geometry", "");
@@ -69,7 +69,7 @@ TEST_CASE("check index with single column", "[NoDB]")
6969

7070
TEST_CASE("check index with multiple columns", "[NoDB]")
7171
{
72-
test_framework const tf;
72+
test_framework_t const tf;
7373

7474
flex_table_t table{"public", "test_table", 0};
7575
table.add_column("a", "int", "");
@@ -91,7 +91,7 @@ TEST_CASE("check index with multiple columns", "[NoDB]")
9191

9292
TEST_CASE("check unique index", "[NoDB]")
9393
{
94-
test_framework const tf;
94+
test_framework_t const tf;
9595

9696
flex_table_t table{"public", "test_table", 0};
9797
table.add_column("col", "int", "");
@@ -113,7 +113,7 @@ TEST_CASE("check unique index", "[NoDB]")
113113

114114
TEST_CASE("check index with tablespace from table", "[NoDB]")
115115
{
116-
test_framework const tf;
116+
test_framework_t const tf;
117117

118118
flex_table_t table{"public", "test_table", 0};
119119
table.set_index_tablespace("foo");
@@ -135,7 +135,7 @@ TEST_CASE("check index with tablespace from table", "[NoDB]")
135135

136136
TEST_CASE("check index with tablespace", "[NoDB]")
137137
{
138-
test_framework const tf;
138+
test_framework_t const tf;
139139

140140
flex_table_t table{"public", "test_table", 0};
141141
table.add_column("col", "int", "");
@@ -157,7 +157,7 @@ TEST_CASE("check index with tablespace", "[NoDB]")
157157

158158
TEST_CASE("check index with expression and where clause", "[NoDB]")
159159
{
160-
test_framework const tf;
160+
test_framework_t const tf;
161161

162162
flex_table_t table{"public", "test_table", 0};
163163
table.add_column("col", "text", "");
@@ -179,7 +179,7 @@ TEST_CASE("check index with expression and where clause", "[NoDB]")
179179

180180
TEST_CASE("check index with include", "[NoDB]")
181181
{
182-
test_framework const tf;
182+
test_framework_t const tf;
183183

184184
flex_table_t table{"public", "test_table", 0};
185185
table.add_column("col", "int", "");
@@ -202,7 +202,7 @@ TEST_CASE("check index with include", "[NoDB]")
202202

203203
TEST_CASE("check index with include as array", "[NoDB]")
204204
{
205-
test_framework const tf;
205+
test_framework_t const tf;
206206

207207
flex_table_t table{"public", "test_table", 0};
208208
table.add_column("col", "int", "");
@@ -225,7 +225,7 @@ TEST_CASE("check index with include as array", "[NoDB]")
225225

226226
TEST_CASE("check index with empty include array", "[NoDB]")
227227
{
228-
test_framework const tf;
228+
test_framework_t const tf;
229229

230230
flex_table_t table{"public", "test_table", 0};
231231
table.add_column("col", "int", "");
@@ -248,7 +248,7 @@ TEST_CASE("check index with empty include array", "[NoDB]")
248248

249249
TEST_CASE("check multiple indexes", "[NoDB]")
250250
{
251-
test_framework const tf;
251+
test_framework_t const tf;
252252

253253
flex_table_t table{"public", "test_table", 0};
254254
table.add_column("a", "int", "");
@@ -271,7 +271,7 @@ TEST_CASE("check multiple indexes", "[NoDB]")
271271

272272
TEST_CASE("check various broken index configs", "[NoDB]")
273273
{
274-
test_framework const tf;
274+
test_framework_t const tf;
275275

276276
flex_table_t table{"public", "test_table", 0};
277277
table.add_column("col", "text", "");

tests/test-util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ TEST_CASE("human readable time durations", "[NoDB]")
4444

4545
TEST_CASE("find_by_name()", "[NoDB]")
4646
{
47-
class test_class
47+
class test_class_t
4848
{
4949
public:
50-
explicit test_class(std::string n) : m_name(std::move(n)) {}
50+
explicit test_class_t(std::string n) : m_name(std::move(n)) {}
5151
std::string name() const noexcept { return m_name; }
5252

5353
private:
5454
std::string m_name;
5555
};
5656

57-
std::vector<test_class> t;
57+
std::vector<test_class_t> t;
5858

5959
REQUIRE(util::find_by_name(t, "") == nullptr);
6060
REQUIRE(util::find_by_name(t, "foo") == nullptr);

0 commit comments

Comments
 (0)