Skip to content

Commit 22a7c30

Browse files
committed
clang-tidy
1 parent 79d5ffa commit 22a7c30

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Checks: >-
2929
performance-*,
3030
readability-*,
3131
-readability-avoid-const-params-in-decls,
32+
-readability-function-cognitive-complexity,
3233
-readability-identifier-length,
3334
-readability-magic-numbers,
3435

include/tao/json/cbor/events/to_stream.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,35 @@ namespace tao::json::cbor::events
3434

3535
void null()
3636
{
37-
os.put( char( std::uint8_t( internal::major::OTHER ) + 22 ) );
37+
os.put( static_cast< char >( static_cast< std::uint8_t >( internal::major::OTHER ) + 22 ) );
3838
}
3939

4040
void boolean( const bool v )
4141
{
42-
os.put( char( std::uint8_t( internal::major::OTHER ) + 20 + std::uint8_t( v ) ) );
42+
os.put( static_cast< char >( static_cast< std::uint8_t >( internal::major::OTHER ) + 20 + static_cast< std::uint8_t >( v ) ) );
4343
}
4444

4545
void number( const internal::major m, const std::uint64_t v )
4646
{
4747
if( v < 24 ) {
48-
os.put( char( std::uint8_t( m ) + v ) );
48+
os.put( static_cast< char >( static_cast< std::uint8_t >( m ) + v ) );
4949
}
5050
else if( v < 256 ) {
51-
os.put( char( std::uint8_t( m ) + 24 ) );
52-
os.put( char( v ) );
51+
os.put( static_cast< char >( static_cast< std::uint8_t >( m ) + 24 ) );
52+
os.put( static_cast< char >( v ) );
5353
}
5454
else if( v < 65536 ) {
55-
os.put( char( std::uint8_t( m ) + 25 ) );
56-
const std::uint16_t x = json::internal::h_to_be( std::uint16_t( v ) );
55+
os.put( static_cast< char >( static_cast< std::uint8_t >( m ) + 25 ) );
56+
const std::uint16_t x = json::internal::h_to_be( static_cast< std::uint16_t >( v ) );
5757
os.write( reinterpret_cast< const char* >( &x ), sizeof( x ) );
5858
}
5959
else if( v < 4294967296ULL ) {
60-
os.put( char( std::uint8_t( m ) + 26 ) );
61-
const std::uint32_t x = json::internal::h_to_be( std::uint32_t( v ) );
60+
os.put( static_cast< char >( static_cast< std::uint8_t >( m ) + 26 ) );
61+
const std::uint32_t x = json::internal::h_to_be( static_cast< std::uint32_t >( v ) );
6262
os.write( reinterpret_cast< const char* >( &x ), sizeof( x ) );
6363
}
6464
else {
65-
os.put( char( std::uint8_t( m ) + 27 ) );
65+
os.put( static_cast< char >( static_cast< std::uint8_t >( m ) + 27 ) );
6666
const std::uint64_t x = json::internal::h_to_be( v );
6767
os.write( reinterpret_cast< const char* >( &x ), sizeof( x ) );
6868
}
@@ -88,7 +88,7 @@ namespace tao::json::cbor::events
8888
std::uint64_t n;
8989
std::memcpy( &n, &v, sizeof( n ) );
9090
n = json::internal::h_to_be( n );
91-
os.put( char( std::uint8_t( internal::major::OTHER ) + 27 ) );
91+
os.put( static_cast< char >( static_cast< std::uint8_t >( internal::major::OTHER ) + 27 ) );
9292
os.write( reinterpret_cast< const char* >( &n ), sizeof( n ) );
9393
}
9494

@@ -106,7 +106,7 @@ namespace tao::json::cbor::events
106106

107107
void begin_array()
108108
{
109-
os.put( char( std::uint8_t( internal::major::ARRAY ) + internal::minor_mask ) );
109+
os.put( static_cast< char >( static_cast< std::uint8_t >( internal::major::ARRAY ) + internal::minor_mask ) );
110110
}
111111

112112
void begin_array( const std::size_t size )
@@ -119,15 +119,15 @@ namespace tao::json::cbor::events
119119

120120
void end_array()
121121
{
122-
os.put( char( 0xff ) );
122+
os.put( static_cast< char >( 0xff ) );
123123
}
124124

125125
void end_array( const std::size_t /*unused*/ ) noexcept
126126
{}
127127

128128
void begin_object()
129129
{
130-
os.put( char( std::uint8_t( internal::major::OBJECT ) + internal::minor_mask ) );
130+
os.put( static_cast< char >( static_cast< std::uint8_t >( internal::major::OBJECT ) + internal::minor_mask ) );
131131
}
132132

133133
void begin_object( const std::size_t size )
@@ -145,7 +145,7 @@ namespace tao::json::cbor::events
145145

146146
void end_object()
147147
{
148-
os.put( char( 0xff ) );
148+
os.put( static_cast< char >( 0xff ) );
149149
}
150150

151151
void end_object( const std::size_t /*unused*/ ) noexcept

include/tao/json/cbor/parts_parser.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ namespace tao::json::cbor
6262
{
6363
const auto b = json::internal::peek_uint8( in );
6464
switch( b ) {
65-
case std::uint8_t( major::OTHER ) + 20:
66-
case std::uint8_t( major::OTHER ) + 21:
65+
case static_cast< std::uint8_t >( major::OTHER ) + 20:
66+
case static_cast< std::uint8_t >( major::OTHER ) + 21:
6767
in.bump_in_this_line( 1 );
68-
return bool( b - std::uint8_t( major::OTHER ) - 20 );
68+
return static_cast< bool >( b - static_cast< std::uint8_t >( major::OTHER ) - 20 );
6969
default:
7070
throw pegtl::parse_error( "expected boolean", in );
7171
}
@@ -84,8 +84,7 @@ namespace tao::json::cbor
8484
template< typename... Ts >
8585
explicit basic_parts_parser( Ts&&... ts )
8686
: m_input( std::forward< Ts >( ts )... )
87-
{
88-
}
87+
{}
8988

9089
[[nodiscard]] bool empty()
9190
{
@@ -94,7 +93,7 @@ namespace tao::json::cbor
9493

9594
[[nodiscard]] bool null()
9695
{
97-
if( json::internal::peek_uint8( m_input ) == std::uint8_t( internal::major::OTHER ) + 22 ) {
96+
if( json::internal::peek_uint8( m_input ) == static_cast< std::uint8_t >( internal::major::OTHER ) + 22 ) {
9897
m_input.bump_in_this_line( 1 );
9998
return true;
10099
}
@@ -144,7 +143,7 @@ namespace tao::json::cbor
144143
[[nodiscard]] std::string_view string_view()
145144
{
146145
const auto b = json::internal::peek_uint8( m_input );
147-
if( b != std::uint8_t( internal::major::STRING ) + internal::minor_mask ) {
146+
if( b != static_cast< std::uint8_t >( internal::major::STRING ) + internal::minor_mask ) {
148147
throw pegtl::parse_error( "expected definitive string", m_input );
149148
}
150149
return internal::read_string_1< V, std::string_view >( m_input );
@@ -153,7 +152,7 @@ namespace tao::json::cbor
153152
[[nodiscard]] tao::binary_view binary_view()
154153
{
155154
const auto b = json::internal::peek_uint8( m_input );
156-
if( b != std::uint8_t( internal::major::BINARY ) + internal::minor_mask ) {
155+
if( b != static_cast< std::uint8_t >( internal::major::BINARY ) + internal::minor_mask ) {
157156
throw pegtl::parse_error( "expected definitive binary", m_input );
158157
}
159158
return internal::read_string_1< utf8_mode::trust, tao::binary_view >( m_input );
@@ -171,7 +170,7 @@ namespace tao::json::cbor
171170
if( u > 9223372036854775807ULL ) {
172171
throw pegtl::parse_error( "positive integer overflow", m_input );
173172
}
174-
return std::int64_t( u );
173+
return static_cast< std::int64_t >( u );
175174
}
176175

177176
[[nodiscard]] std::int64_t number_signed_negative()
@@ -180,7 +179,7 @@ namespace tao::json::cbor
180179
if( u > 9223372036854775808ULL ) {
181180
throw pegtl::parse_error( "negative integer overflow", m_input );
182181
}
183-
return std::int64_t( ~u );
182+
return static_cast< std::int64_t >( ~u );
184183
}
185184

186185
#if defined( _MSC_VER )
@@ -215,11 +214,11 @@ namespace tao::json::cbor
215214
{
216215
const auto b = json::internal::peek_uint8( m_input );
217216
switch( b ) {
218-
case std::uint8_t( internal::major::OTHER ) + 25:
217+
case static_cast< std::uint8_t >( internal::major::OTHER ) + 25:
219218
return internal::read_fp16( m_input );
220-
case std::uint8_t( internal::major::OTHER ) + 26:
219+
case static_cast< std::uint8_t >( internal::major::OTHER ) + 26:
221220
return json::internal::read_big_endian_number< float >( m_input + 1 );
222-
case std::uint8_t( internal::major::OTHER ) + 27:
221+
case static_cast< std::uint8_t >( internal::major::OTHER ) + 27:
223222
return json::internal::read_big_endian_number< double >( m_input + 1 );
224223
default:
225224
throw pegtl::parse_error( "expected floating point number", m_input );

include/tao/json/contrib/deque_traits.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define TAO_JSON_CONTRIB_DEQUE_TRAITS_HPP
66

77
#include <deque>
8+
#include <vector>
89

910
#include "../consume.hpp"
1011
#include "../forward.hpp"

0 commit comments

Comments
 (0)