Skip to content

Commit b4db64a

Browse files
committed
Mark multiple things with NOSONAR
1 parent 298d0e2 commit b4db64a

12 files changed

+29
-29
lines changed

examples/threadqueue/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ std::int32_t main() {
9393

9494
std::cout << "bad_alloc: " << _exception.what() << std::endl;
9595
}
96-
catch ( const std::exception &_exception ) {
96+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
9797

9898
std::cout << _exception.what() << std::endl;
9999
}
@@ -116,7 +116,7 @@ std::int32_t main() {
116116

117117
std::cout << "bad_alloc: " << _exception.what() << std::endl;
118118
}
119-
catch ( const std::exception &_exception ) {
119+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
120120

121121
std::cout << _exception.what() << std::endl;
122122
}
@@ -148,7 +148,7 @@ std::int32_t main() {
148148

149149
std::cout << "bad_alloc: " << _exception.what() << std::endl;
150150
}
151-
catch ( const std::exception &_exception ) {
151+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
152152

153153
std::cout << _exception.what() << std::endl;
154154
}

source/Demangle.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace vx::demangle {
6969
const std::unique_ptr<char, void ( * )( char * )> res {
7070

7171
abi::__cxa_demangle( _name.c_str(), nullptr, nullptr, &status ),
72-
[]( char *_toFree ) { std::free( _toFree ); }
72+
[]( char *_toFree ) { std::free( _toFree ); } // NOSONAR raii is nor possible here.
7373
};
7474

7575
if ( status == 0 ) {
@@ -140,7 +140,7 @@ namespace vx::demangle {
140140

141141
logFatal() << "bad_alloc:" << _exception.what();
142142
}
143-
catch ( const std::exception &_exception ) {
143+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
144144

145145
logFatal() << _exception.what();
146146
}

source/Serial.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace vx {
159159

160160
logFatal() << "bad_alloc:" << _exception.what();
161161
}
162-
catch ( const std::exception &_exception ) {
162+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
163163

164164
logFatal() << _exception.what();
165165
}
@@ -184,7 +184,7 @@ namespace vx {
184184

185185
logFatal() << "bad_alloc:" << _exception.what();
186186
}
187-
catch ( const std::exception &_exception ) {
187+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
188188

189189
logFatal() << _exception.what();
190190
}
@@ -209,7 +209,7 @@ namespace vx {
209209

210210
logFatal() << "bad_alloc:" << _exception.what();
211211
}
212-
catch ( const std::exception &_exception ) {
212+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
213213

214214
logFatal() << _exception.what();
215215
}
@@ -224,7 +224,7 @@ namespace vx {
224224

225225
logFatal() << "bad_alloc:" << _exception.what();
226226
}
227-
catch ( const std::exception &_exception ) {
227+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
228228

229229
logFatal() << _exception.what();
230230
}

source/StringUtils.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include "Logger.h"
5050
#include "StringUtils.h"
5151

52-
namespace std { // NOSONAR
52+
namespace std { // NOSONAR for std integration.
5353

5454
#if defined _MSC_VER && _MSC_VER < 1920
5555
using ::isspace;
@@ -249,11 +249,11 @@ namespace vx::string_utils {
249249
logFatal() << _exception.what();
250250
}
251251
#ifdef _WIN32
252-
size = std::strnlen_s( reinterpret_cast<const char *>( _uchr ), string.size() ); // NOSONAR do not use reinterpret_cast
252+
size = std::strnlen_s( reinterpret_cast<const char *>( _uchr ), string.size() ); // NOSONAR do not use reinterpret_cast.
253253
#else
254-
size = std::strnlen( reinterpret_cast<const char *>( _uchr ), string.size() ); // NOSONAR do not use reinterpret_cast
254+
size = std::strnlen( reinterpret_cast<const char *>( _uchr ), string.size() ); // NOSONAR do not use reinterpret_cast.
255255
#endif
256256
}
257-
return std::make_optional<std::string>( _uchr, _uchr + size ); // NOSONAR do not use pointer arithmetic
257+
return std::make_optional<std::string>( _uchr, _uchr + size ); // NOSONAR do not use pointer arithmetic.
258258
}
259259
}

source/Timestamp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace vx::timestamp {
107107
nowSs << offset.str();
108108
result = nowSs.str();
109109
}
110-
catch ( const std::exception &_exception ) {
110+
catch ( const std::exception &_exception ) { // NOSONAR fallback for every exeption.
111111

112112
logFatal() << _exception.what();
113113
}

source/templates/Cpp23.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/**
4141
* @brief std (Standard template library) namespace.
4242
*/
43-
namespace std { // NOSONAR For std integration
43+
namespace std { // NOSONAR for std integration.
4444

4545
#ifndef __cpp_lib_is_scoped_enum
4646
namespace detail {

source/templates/SharedQueue.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace vx {
9393
*/
9494
T front() noexcept {
9595

96-
std::unique_lock<std::shared_mutex> lock( m_mutex );
96+
std::unique_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template reduction not possible.
9797
m_condition.wait( lock, [ this ] { return !m_queue.empty(); } );
9898

9999
T tmp = m_queue.front();
@@ -107,7 +107,7 @@ namespace vx {
107107
*/
108108
void push( const T &item ) noexcept {
109109

110-
std::unique_lock<std::shared_mutex> lock( m_mutex );
110+
std::unique_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template reduction not possible.
111111

112112
m_queue.push( item );
113113

@@ -124,7 +124,7 @@ namespace vx {
124124
*/
125125
void push( T &&item ) noexcept {
126126

127-
std::unique_lock<std::shared_mutex> lock( m_mutex );
127+
std::unique_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template reduction not possible.
128128

129129
m_queue.push( std::move( item ) );
130130

@@ -141,7 +141,7 @@ namespace vx {
141141
*/
142142
std::size_t size() const noexcept {
143143

144-
std::shared_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction
144+
std::shared_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction.
145145

146146
std::size_t size = m_queue.size();
147147

@@ -155,7 +155,7 @@ namespace vx {
155155
*/
156156
bool empty() const noexcept {
157157

158-
std::shared_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction
158+
std::shared_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction.
159159

160160
bool empty = m_queue.empty();
161161

source/templates/Timer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace vx {
122122
*/
123123
inline void stop() noexcept {
124124

125-
const std::unique_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction
125+
const std::unique_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction.
126126
m_clear = true;
127127
}
128128

@@ -132,7 +132,7 @@ namespace vx {
132132
*/
133133
[[nodiscard]] inline bool isRunning() const noexcept {
134134

135-
const std::shared_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction
135+
const std::shared_lock<std::shared_mutex> lock( m_mutex ); // NOSONAR template argument deduction.
136136
return !m_clear;
137137
}
138138

source/unixservice/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ std::int32_t main() {
100100
::close( pos );
101101
}
102102
/* Alternative, sometimes it is needed not to close all file descriptors */
103-
// ::close( STDIN_FILENO ); // NOSONAR possible alternative solution
104-
// ::close( STDOUT_FILENO ); // NOSONAR possible alternative solution
105-
// ::close( STDERR_FILENO ); // NOSONAR possible alternative solution
103+
// ::close( STDIN_FILENO ); // NOSONAR possible alternative solution.
104+
// ::close( STDOUT_FILENO ); // NOSONAR possible alternative solution.
105+
// ::close( STDERR_FILENO ); // NOSONAR possible alternative solution.
106106

107107
/* Ensure only one copy */
108108
std::ostringstream ostream {};

tests/test_demangle.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace vx {
6868
BLUE = 4,
6969
GREEN = 8 };
7070

71-
enum ColorUnscoped { RED = 2, // NOSONAR Just for testing purpose
71+
enum ColorUnscoped { RED = 2, // NOSONAR just for testing purpose.
7272
BLUE = 4,
7373
GREEN = 8 };
7474

tests/test_magic_enum.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ namespace vx {
316316

317317
TEST( MagicEnum, Checks ) {
318318

319-
enum ColorUnscoped { RED = 2, // NOSONAR Just for testing purpose
319+
enum ColorUnscoped { RED = 2, // NOSONAR just for testing purpose.
320320
BLUE = 4,
321321
GREEN = 8 };
322322

tests/test_string_utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace vx {
169169
#endif
170170
inline void badCaseWrongSizeCheck() {
171171

172-
unsigned char chrArray[] = "The answer is 42."; // NOSONAR Just for testing purpose
172+
unsigned char chrArray[] = "The answer is 42."; // NOSONAR just for testing purpose.
173173
const unsigned char *chrPointer = chrArray;
174174

175175
/* A sanitizer will found that issue, so this is not usable for regular testing. */
@@ -178,7 +178,7 @@ namespace vx {
178178

179179
TEST( StringUtils, FromUnsignedChar ) {
180180

181-
unsigned char chrArray[] = "The answer is 42."; // NOSONAR Just for testing purpose
181+
unsigned char chrArray[] = "The answer is 42."; // NOSONAR just for testing purpose.
182182
const unsigned char *chrPointer = chrArray;
183183
EXPECT_EQ( string_utils::fromUnsignedChar( chrPointer ), "The answer is 42." );
184184
EXPECT_EQ( string_utils::MAYBE_BAD_fromUnsignedChar( chrPointer, 0 ), "The answer is 42." );

0 commit comments

Comments
 (0)