Skip to content

Commit a216428

Browse files
authored
Merge pull request #119 from joto/clang-tidy-fixes
Clang tidy fixes
2 parents a7dab95 + c8f8994 commit a216428

File tree

13 files changed

+45
-45
lines changed

13 files changed

+45
-45
lines changed

include/protozero/basic_pbf_builder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class basic_pbf_builder : public basic_pbf_writer<TBuffer> {
6767
* @param tag Tag of the field that will be written
6868
*/
6969
template <typename P>
70-
basic_pbf_builder(basic_pbf_writer<TBuffer>& parent_writer, P tag) noexcept :
70+
basic_pbf_builder(basic_pbf_writer<TBuffer>& parent_writer, P tag) :
7171
basic_pbf_writer<TBuffer>{parent_writer, pbf_tag_type(tag)} {
7272
}
7373

test/include/packed_access.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ TEST_CASE("write repeated packed field using packed field: " PBF_TYPE_NAME) {
153153

154154
SECTION("empty - should do rollback") {
155155
{
156-
packed_field_type field{pw, 1};
156+
const packed_field_type field{pw, 1};
157157
}
158158

159159
REQUIRE(buffer == load_data("repeated_packed_" PBF_TYPE_NAME "/data-empty"));
@@ -264,7 +264,7 @@ TEST_CASE("write from different types of iterators: " PBF_TYPE_NAME) {
264264
}
265265

266266
SECTION("from string") {
267-
std::string data{"1 4 9 16 25"};
267+
const std::string data{"1 4 9 16 25"};
268268
std::stringstream sdata{data};
269269

270270
#if PBF_TYPE_IS_SIGNED
@@ -273,8 +273,8 @@ TEST_CASE("write from different types of iterators: " PBF_TYPE_NAME) {
273273
using test_type = uint32_t;
274274
#endif
275275

276-
std::istream_iterator<test_type> eod;
277-
std::istream_iterator<test_type> it(sdata);
276+
const std::istream_iterator<test_type> eod;
277+
const std::istream_iterator<test_type> it(sdata);
278278

279279
pw.ADD_TYPE(1, it, eod);
280280
}

test/include/test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct assert_error : public std::runtime_error {
1313
explicit assert_error(const char* what_arg) : std::runtime_error(what_arg) {
1414
}
1515
};
16-
#define protozero_assert(x) if (!(x)) { throw assert_error{#x}; }
16+
#define protozero_assert(x) if (!(x)) { throw assert_error{#x}; } // NOLINT(readability-simplify-boolean-expr)
1717

1818
#include <protozero/pbf_builder.hpp>
1919
#include <protozero/pbf_message.hpp>

test/t/bytes/reader_test_cases.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,32 @@ TEST_CASE("write bytes field using vectored approach") {
9191
protozero::pbf_writer pw{buffer};
9292

9393
SECTION("using two strings") {
94-
std::string d1{"foo"};
95-
std::string d2{"bar"};
94+
const std::string d1{"foo"};
95+
const std::string d2{"bar"};
9696

9797
pw.add_bytes_vectored(1, d1, d2);
9898
}
9999

100100
SECTION("using a string and a dataview") {
101-
std::string d1{"foo"};
102-
std::string d2{"bar"};
103-
protozero::data_view dv{d2};
101+
const std::string d1{"foo"};
102+
const std::string d2{"bar"};
103+
const protozero::data_view dv{d2};
104104

105105
pw.add_bytes_vectored(1, d1, dv);
106106
}
107107

108108
SECTION("using three strings") {
109-
std::string d1{"foo"};
110-
std::string d2{"ba"};
111-
std::string d3{"r"};
109+
const std::string d1{"foo"};
110+
const std::string d2{"ba"};
111+
const std::string d3{"r"};
112112

113113
pw.add_bytes_vectored(1, d1, d2, d3);
114114
}
115115

116116
SECTION("with empty string") {
117-
std::string d1{"foo"};
118-
std::string d2{};
119-
std::string d3{"bar"};
117+
const std::string d1{"foo"};
118+
const std::string d2{};
119+
const std::string d3{"bar"};
120120

121121
pw.add_bytes_vectored(1, d1, d2, d3);
122122
}

test/t/message/reader_test_cases.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ TEST_CASE("write message field") {
6767
}
6868

6969
SECTION("string with subwriter with reserved size") {
70-
std::string str{"foobar"};
70+
const std::string str{"foobar"};
7171
const auto size = 1 /* tag */ + 1 /* length field */ + str.size();
7272
protozero::pbf_writer pbf_submessage{pbf_test, 1, size};
7373
pbf_submessage.add_string(1, "foobar");

test/t/nested/reader_test_cases.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ inline void check_empty(protozero::pbf_reader message) {
8080
TEST_CASE("read nested message fields: string") {
8181
const std::string buffer = load_data("nested/data-message");
8282

83-
protozero::pbf_reader message{buffer};
83+
const protozero::pbf_reader message{buffer};
8484
check(message);
8585
}
8686

8787
TEST_CASE("read nested message fields: no submessage") {
8888
const std::string buffer = load_data("nested/data-no-message");
8989

90-
protozero::pbf_reader message{buffer};
90+
const protozero::pbf_reader message{buffer};
9191
check_empty(message);
9292
}
9393

@@ -121,7 +121,7 @@ TEST_CASE("write nested message fields") {
121121

122122
pbf_test.add_int32(2, 77);
123123

124-
protozero::pbf_reader message{buffer_test};
124+
const protozero::pbf_reader message{buffer_test};
125125
check(message);
126126
}
127127

@@ -133,25 +133,25 @@ TEST_CASE("write nested message fields - no message") {
133133
}
134134

135135
SECTION("empty string") {
136-
std::string buffer_sub;
136+
const std::string buffer_sub;
137137

138138
pbf_test.add_message(1, buffer_sub);
139139
}
140140

141141
SECTION("string with pbf_writer") {
142142
std::string buffer_sub;
143-
protozero::pbf_writer pbf_sub{buffer_sub};
143+
const protozero::pbf_writer pbf_sub{buffer_sub};
144144

145145
pbf_test.add_message(1, buffer_sub);
146146
}
147147

148148
SECTION("string with subwriter") {
149-
protozero::pbf_writer pbf_sub{pbf_test, 1};
149+
const protozero::pbf_writer pbf_sub{pbf_test, 1};
150150
}
151151

152152
pbf_test.add_int32(2, 77);
153153

154-
protozero::pbf_reader message{buffer_test};
154+
const protozero::pbf_reader message{buffer_test};
155155
check_empty(message);
156156
}
157157

test/t/repeated_packed_bool/reader_test_cases.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ TEST_CASE("write repeated packed bool field using packed_field_bool") {
9090

9191
SECTION("empty - should do rollback") {
9292
{
93-
protozero::packed_field_bool field{pw, 1};
93+
const protozero::packed_field_bool field{pw, 1};
9494
}
9595

9696
REQUIRE(buffer == load_data("repeated_packed_bool/data-empty"));
@@ -128,7 +128,7 @@ TEST_CASE("write repeated packed bool field using packed_field_bool with pbf_bui
128128

129129
SECTION("empty - should do rollback") {
130130
{
131-
protozero::packed_field_bool field{pw, msg::f};
131+
const protozero::packed_field_bool field{pw, msg::f};
132132
}
133133

134134
REQUIRE(buffer == load_data("repeated_packed_bool/data-empty"));

test/t/repeated_packed_fixed32/writer_test_cases.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ TEMPLATE_TEST_CASE("write from different types of iterators and check with libpr
5858
}
5959

6060
SECTION("from string") {
61-
std::string data = "1 4 9 16 25";
61+
const std::string data = "1 4 9 16 25";
6262
std::stringstream sdata(data);
6363

64-
std::istream_iterator<uint32_t> eod;
65-
std::istream_iterator<uint32_t> it(sdata);
64+
const std::istream_iterator<uint32_t> eod;
65+
const std::istream_iterator<uint32_t> it(sdata);
6666

6767
pw.template add_packed_fixed<uint32_t>(1, it, eod);
6868
}

test/t/rollback/reader_test_cases.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TEST_CASE("rollback when using packed_field functions") {
1010

1111
SECTION("empty - should do rollback") {
1212
{
13-
protozero::packed_field_sint64 field{pw, 1};
13+
const protozero::packed_field_sint64 field{pw, 1};
1414
}
1515

1616
pw.add_int32(4, 123);
@@ -197,7 +197,7 @@ TEST_CASE("rollback on message is not allowed if there is a nested submessage")
197197
{
198198
protozero::pbf_writer pws{pw, 1};
199199
pws.add_string(1, "foobar");
200-
protozero::pbf_writer pws2{pws, 1};
200+
const protozero::pbf_writer pws2{pws, 1};
201201
REQUIRE_THROWS_AS(pws.rollback(), assert_error);
202202
}
203203
}

test/t/vector_tile/reader_test_cases.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ TEST_CASE("reading vector tiles") {
7878
int n_geomtype = 0;
7979
while (item.next(3)) { // repeated message Layer
8080
protozero::pbf_reader layer{item.get_message()};
81-
std::string name = get_name(layer);
81+
const std::string name = get_name(layer);
8282
if (name == "road") {
8383
while (layer.next(2)) { // repeated Feature
8484
++n;
@@ -118,7 +118,7 @@ TEST_CASE("reading vector tiles") {
118118
int n_geomtype = 0;
119119
while (item.next(3)) { // repeated message Layer
120120
protozero::pbf_reader layer{item.get_message()};
121-
std::string name = get_name(layer);
121+
const std::string name = get_name(layer);
122122
if (name == "road") {
123123
while (layer.next(2)) { // repeated Feature
124124
++n;

0 commit comments

Comments
 (0)