Skip to content

Commit 072fb58

Browse files
committed
clang-tidy
1 parent b16af2e commit 072fb58

13 files changed

+51
-41
lines changed

include/tao/json/contrib/patch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace tao::json
4242
throw std::runtime_error( internal::format( "json patch 'test' failed for '", path, '\'', json::message_extension( v ) ) );
4343
}
4444
auto t = std::move( v.at( from ) );
45-
v.erase( from );
45+
v.erase( from ); // NOLINT(clang-analyzer-cplusplus.Move)
4646
v.insert( path_pointer, std::move( t ) );
4747
}
4848
else if( op == "copy" ) {

src/example/json/jaxn_to_cplusplus.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace tao::json::cplusplus::events
1111
{
1212
protected:
1313
std::ostream& os;
14-
char buffer[ 32 ];
14+
char buffer[ 32 ] = {};
1515
const std::size_t indent;
1616
const std::string eol;
1717

@@ -26,7 +26,7 @@ namespace tao::json::cplusplus::events
2626
std::size_t len = current_indent;
2727
while( len != 0 ) {
2828
const auto chunk = ( std::min )( indent, sizeof( buffer ) );
29-
os.write( buffer, chunk );
29+
os.write( buffer, static_cast< std::streamsize >( chunk ) );
3030
len -= chunk;
3131
}
3232
}
@@ -47,7 +47,6 @@ namespace tao::json::cplusplus::events
4747
public:
4848
to_pretty_stream( std::ostream& in_os, const std::size_t in_indent )
4949
: os( in_os ),
50-
buffer(),
5150
indent( in_indent ),
5251
eol( "\n" )
5352
{
@@ -113,9 +112,9 @@ namespace tao::json::cplusplus::events
113112
next();
114113
os << "tao::binary({ ";
115114
if( !v.empty() ) {
116-
os << "std::byte(" << int( v[ 0 ] ) << ")";
115+
os << "std::byte(" << static_cast< int >( v[ 0 ] ) << ")";
117116
for( std::size_t j = 1; j < v.size(); ++j ) {
118-
os << ", std::byte(" << int( v[ j ] ) << ")";
117+
os << ", std::byte(" << static_cast< int >( v[ j ] ) << ")";
119118
}
120119
}
121120
os.write( " })", 3 );

src/example/json/printf_doubles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace tao::json::events
2222
}
2323
char buffer[ 32 ];
2424
const std::size_t n = std::snprintf( buffer, sizeof( buffer ), "%0.2f", v );
25-
os.write( buffer, n );
25+
os.write( buffer, static_cast< std::streamsize >( n ) );
2626
}
2727

2828
void number( const std::int64_t v )

src/example/json/validate_integer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ namespace tao::json
1919
: public Consumer
2020
{
2121
static_assert( Max >= Min );
22-
static_assert( Max <= std::uint64_t( ( std::numeric_limits< std::int64_t >::max )() ), "Max may not be larger than 2^63-1" );
22+
static_assert( Max <= static_cast< std::uint64_t >( ( std::numeric_limits< std::int64_t >::max )() ), "Max may not be larger than 2^63-1" );
2323

2424
using Consumer::Consumer;
2525

2626
void number( const std::int64_t v )
2727
{
28-
if( ( v < std::int64_t( Min ) ) || ( v > std::int64_t( Max ) ) ) {
28+
if( ( v < static_cast< std::int64_t >( Min ) ) || ( v > static_cast< std::int64_t >( Max ) ) ) {
2929
throw std::runtime_error( "integer range violated: " + std::to_string( v ) );
3030
}
3131
Consumer::number( v );

src/test/json/big_list_of_naughty_strings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
in.seekg( 0, std::ios::end );
2020
contents.resize( static_cast< std::string::size_type >( in.tellg() ) );
2121
in.seekg( 0, std::ios::beg );
22-
in.read( &contents[ 0 ], contents.size() );
22+
in.read( contents.data(), static_cast< std::streamsize >( contents.size() ) );
2323
in.close();
2424
return contents;
2525
}

src/test/json/cbor.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ namespace tao::json
6262

6363
cbor_encode( "\"0\"", "6130" );
6464

65-
cbor_encode( '"' + std::string( std::size_t( 23 ), 'D' ) + '"', "77" + std::string( std::size_t( 46 ), '4' ) );
66-
cbor_encode( '"' + std::string( std::size_t( 24 ), 'D' ) + '"', "7818" + std::string( std::size_t( 48 ), '4' ) );
67-
cbor_encode( '"' + std::string( std::size_t( 255 ), 'D' ) + '"', "78ff" + std::string( std::size_t( 510 ), '4' ) );
68-
cbor_encode( '"' + std::string( std::size_t( 256 ), 'D' ) + '"', "790100" + std::string( std::size_t( 512 ), '4' ) );
69-
cbor_encode( '"' + std::string( std::size_t( 65535 ), 'D' ) + '"', "79ffff" + std::string( std::size_t( 131070 ), '4' ) );
70-
cbor_encode( '"' + std::string( std::size_t( 65536 ), 'D' ) + '"', "7a00010000" + std::string( std::size_t( 131072 ), '4' ) );
71-
72-
// cbor_encode( '"' + std::string( std::size_t( 4294967295 ), 'D' ) + '"', "7affffffff" + std::string( std::size_t( 8589934590 ), '4' ) ); // Uses 24GB of RAM.
73-
// cbor_encode( '"' + std::string( std::size_t( 4294967296 ), 'D' ) + '"', "7b0000000100000000" + std::string( std::size_t( 8589934592 ), '4' ) ); // Uses 24GB of RAM.
65+
cbor_encode( '"' + std::string( static_cast< std::size_t >( 23 ), 'D' ) + '"', "77" + std::string( static_cast< std::size_t >( 46 ), '4' ) );
66+
cbor_encode( '"' + std::string( static_cast< std::size_t >( 24 ), 'D' ) + '"', "7818" + std::string( static_cast< std::size_t >( 48 ), '4' ) );
67+
cbor_encode( '"' + std::string( static_cast< std::size_t >( 255 ), 'D' ) + '"', "78ff" + std::string( static_cast< std::size_t >( 510 ), '4' ) );
68+
cbor_encode( '"' + std::string( static_cast< std::size_t >( 256 ), 'D' ) + '"', "790100" + std::string( static_cast< std::size_t >( 512 ), '4' ) );
69+
cbor_encode( '"' + std::string( static_cast< std::size_t >( 65535 ), 'D' ) + '"', "79ffff" + std::string( static_cast< std::size_t >( 131070 ), '4' ) );
70+
cbor_encode( '"' + std::string( static_cast< std::size_t >( 65536 ), 'D' ) + '"', "7a00010000" + std::string( static_cast< std::size_t >( 131072 ), '4' ) );
71+
72+
// cbor_encode( '"' + std::string( static_cast< std::size_t >( 4294967295 ), 'D' ) + '"', "7affffffff" + std::string( static_cast< std::size_t >( 8589934590 ), '4' ) ); // Uses 24GB of RAM.
73+
// cbor_encode( '"' + std::string( static_cast< std::size_t >( 4294967296 ), 'D' ) + '"', "7b0000000100000000" + std::string( static_cast< std::size_t >( 8589934592 ), '4' ) ); // Uses 24GB of RAM.
7474

7575
cbor_encode( "[]", "80" );
7676
cbor_encode( "{}", "a0" );

src/test/json/events_binary_to.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ namespace tao::json
4343
test_exception( v );
4444
test_hex( v, "\"\"" );
4545

46-
v = binary{ std::byte( 0 ), std::byte( 255 ), std::byte( 42 ), std::byte( 99 ) };
46+
v = binary{ static_cast< std::byte >( 0 ),
47+
static_cast< std::byte >( 255 ),
48+
static_cast< std::byte >( 42 ),
49+
static_cast< std::byte >( 99 ) };
4750

4851
test_base64( v, "\"AP8qYw==\"" );
4952
test_base64url( v, "\"AP8qYw\"" );

src/test/json/jaxn_ostream.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ namespace tao::json
3838
test_simple( INFINITY, "Infinity" );
3939
test_simple( -INFINITY, "-Infinity" );
4040
test_simple( "foo", "\"foo\"" );
41-
test_simple( std::vector< std::byte >( { std::byte( 1 ), std::byte( 2 ), std::byte( 3 ) } ), "$010203" );
41+
test_simple( std::vector< std::byte >( { static_cast< std::byte >( 1 ),
42+
static_cast< std::byte >( 2 ),
43+
static_cast< std::byte >( 3 ) } ),
44+
"$010203" );
4245
test_simple( empty_array, "[]" );
4346
test_simple( value::array( {} ), "[]" );
4447
test_simple( value::array( { 1 } ), "[1]" );
@@ -58,7 +61,10 @@ namespace tao::json
5861
test_pretty( 42, "42" );
5962
test_pretty( 42.1, "42.1" );
6063
test_pretty( "foo", "\"foo\"" );
61-
test_pretty( std::vector< std::byte >( { std::byte( 1 ), std::byte( 2 ), std::byte( 3 ) } ), "$010203" );
64+
test_pretty( std::vector< std::byte >( { static_cast< std::byte >( 1 ),
65+
static_cast< std::byte >( 2 ),
66+
static_cast< std::byte >( 3 ) } ),
67+
"$010203" );
6268
test_pretty( empty_array, "[]" );
6369
test_pretty( value::array( {} ), "[]" );
6470
test_pretty( value::array( { 1 } ), "[\n 1\n]" );

src/test/json/jaxn_parts_parser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ namespace tao::json
138138
}
139139
{
140140
jaxn::parts_parser p( "$34.00.32", __FUNCTION__ );
141-
const std::vector< std::byte > z = { std::byte( 0x34 ), std::byte( 0x00 ), std::byte( 0x32 ) };
141+
const std::vector< std::byte > z = { static_cast< std::byte >( 0x34 ),
142+
static_cast< std::byte >( 0x00 ),
143+
static_cast< std::byte >( 0x32 ) };
142144
TEST_ASSERT( p.binary() == z );
143145
TEST_ASSERT( p.empty() );
144146
}

src/test/json/msgpack.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace tao::json
3535
msgpack_encode( "\"000\"", "a3303030" );
3636
msgpack_encode( "\"01234567890123456789\"", "b43031323334353637383930313233343536373839" );
3737
msgpack_encode( "\"0123456789012345678901234567890123456789\"", "d92830313233343536373839303132333435363738393031323334353637383930313233343536373839" );
38-
msgpack_encode( "\"" + std::string( std::size_t( 500 ), 'f' ) + "\"", "da01f4" + std::string( std::size_t( 1000 ), '6' ) );
39-
msgpack_encode( "\"" + std::string( std::size_t( 70000 ), 'f' ) + "\"", "db00011170" + std::string( std::size_t( 140000 ), '6' ) );
38+
msgpack_encode( "\"" + std::string( static_cast< std::size_t >( 500 ), 'f' ) + "\"", "da01f4" + std::string( static_cast< std::size_t >( 1000 ), '6' ) );
39+
msgpack_encode( "\"" + std::string( static_cast< std::size_t >( 70000 ), 'f' ) + "\"", "db00011170" + std::string( static_cast< std::size_t >( 140000 ), '6' ) );
4040
msgpack_encode( "0", "00" );
4141
msgpack_encode( "1", "01" );
4242
msgpack_encode( "127", "7f" );
@@ -123,8 +123,8 @@ namespace tao::json
123123
msgpack_decode( "db00000000", "\"\"" );
124124
msgpack_decode( "db0000000138", "\"8\"" );
125125

126-
msgpack_decode( "da01f4" + std::string( std::size_t( 1000 ), '6' ), "\"" + std::string( std::size_t( 500 ), 'f' ) + "\"" );
127-
msgpack_decode( "db00011170" + std::string( std::size_t( 140000 ), '6' ), "\"" + std::string( std::size_t( 70000 ), 'f' ) + "\"" );
126+
msgpack_decode( "da01f4" + std::string( static_cast< std::size_t >( 1000 ), '6' ), "\"" + std::string( static_cast< std::size_t >( 500 ), 'f' ) + "\"" );
127+
msgpack_decode( "db00011170" + std::string( static_cast< std::size_t >( 140000 ), '6' ), "\"" + std::string( static_cast< std::size_t >( 70000 ), 'f' ) + "\"" );
128128

129129
msgpack_decode( "90", "[]" );
130130
msgpack_decode( "80", "{}" );

src/test/json/operators.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ namespace tao::json
129129
template< typename N >
130130
void test_number()
131131
{
132-
const value a( N( 42 ) );
133-
const value b( N( 43 ) );
132+
const value a( static_cast< N >( 42 ) );
133+
const value b( static_cast< N >( 43 ) );
134134

135135
const value pa( &a );
136136
const value pb( &b );
@@ -140,31 +140,31 @@ namespace tao::json
140140
test_lt( a, pb );
141141
test_lt( pa, pb );
142142

143-
test_lt( N( 42 ), b );
143+
test_lt( static_cast< N >( 42 ), b );
144144
test_lt( 42, b );
145145
test_lt( 42U, b );
146146
test_lt( 42.0, b );
147147
test_lt( value( 42 ), b );
148148
test_lt( value( 42U ), b );
149149
test_lt( value( 42.0 ), b );
150150

151-
test_lt( N( 42 ), pb );
151+
test_lt( static_cast< N >( 42 ), pb );
152152
test_lt( 42, pb );
153153
test_lt( 42U, pb );
154154
test_lt( 42.0, pb );
155155
test_lt( value( 42 ), pb );
156156
test_lt( value( 42U ), pb );
157157
test_lt( value( 42.0 ), pb );
158158

159-
test_lt( a, N( 43 ) );
159+
test_lt( a, static_cast< N >( 43 ) );
160160
test_lt( a, 43 );
161161
test_lt( a, 43U );
162162
test_lt( a, 43.0 );
163163
test_lt( a, value( 43 ) );
164164
test_lt( a, value( 43U ) );
165165
test_lt( a, value( 43.0 ) );
166166

167-
test_lt( pa, N( 43 ) );
167+
test_lt( pa, static_cast< N >( 43 ) );
168168
test_lt( pa, 43 );
169169
test_lt( pa, 43U );
170170
test_lt( pa, 43.0 );

src/test/json/validate_event_interfaces.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ namespace tao::json
7373

7474
c->boolean( true );
7575

76-
c->number( int64_t( 0 ) );
77-
c->number( uint64_t( 0 ) );
78-
c->number( double( 0 ) );
76+
c->number( static_cast< std::int64_t >( 0 ) );
77+
c->number( static_cast< std::uint64_t >( 0 ) );
78+
c->number( static_cast< double >( 0 ) );
7979

8080
const char* p = "";
8181
c->string( "" );
@@ -89,15 +89,15 @@ namespace tao::json
8989
c->binary( xv );
9090

9191
c->begin_array();
92-
c->begin_array( std::size_t( 0 ) );
92+
c->begin_array( static_cast< std::size_t >( 0 ) );
9393

9494
c->element();
9595

9696
c->end_array();
97-
c->end_array( std::size_t( 0 ) );
97+
c->end_array( static_cast< std::size_t >( 0 ) );
9898

9999
c->begin_object();
100-
c->begin_object( std::size_t( 0 ) );
100+
c->begin_object( static_cast< std::size_t >( 0 ) );
101101

102102
c->key( "" );
103103
c->key( k );
@@ -107,7 +107,7 @@ namespace tao::json
107107
c->member();
108108

109109
c->end_object();
110-
c->end_object( std::size_t( 0 ) );
110+
c->end_object( static_cast< std::size_t >( 0 ) );
111111
}
112112

113113
template< typename Consumer >

src/test/json/with_arguments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace tao::json
5151
{
5252
[[nodiscard]] static type_2 as( const value& /*unused*/, const arg_0& /*unused*/, const arg_0& /*unused*/ )
5353
{
54-
return type_2();
54+
return {};
5555
}
5656
};
5757

0 commit comments

Comments
 (0)