Skip to content

Commit 33b8cc0

Browse files
committed
Code quality
1 parent c245124 commit 33b8cc0

File tree

10 files changed

+13
-20
lines changed

10 files changed

+13
-20
lines changed

examples/configuration/main.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,11 @@ int main() {
8383
logSomeMessages();
8484

8585
/* remove tmp file */
86-
bool removed = std::filesystem::remove( tmpFile );
87-
if ( !removed ) {
86+
if ( !std::filesystem::remove( tmpFile ) ) {
8887

8988
std::cout << "Tmp file cannot be removed: " << tmpFile << std::endl;
9089
return EXIT_FAILURE;
9190
}
9291
std::cout << "Tmp file was removed: " << tmpFile << std::endl;
9392
return EXIT_SUCCESS;
94-
95-
return EXIT_SUCCESS;
9693
}

examples/threads/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ int main() {
102102
threads.clear();
103103

104104
/* remove tmp file */
105-
bool removed = std::filesystem::remove( tmpFile );
106-
if ( !removed ) {
105+
if ( !std::filesystem::remove( tmpFile ) ) {
107106

108107
std::cout << "Tmp file cannot be removed: " << tmpFile << std::endl;
109108
return EXIT_FAILURE;

source/Logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace vx {
8585
* @brief Create thread-safe timestamp.
8686
* @return Timestamp as 'Y-m-dThh:mm:ss.xxxxxx'
8787
*/
88-
inline const std::string timestamp() noexcept {
88+
inline std::string timestamp() noexcept {
8989

9090
/* get a precise timestamp as a string */
9191
struct std::tm currentLocalTime {};

tests/shared/TestHelper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
/* stl header */
3232
#include <algorithm>
3333
#include <fstream>
34+
#include <iostream>
3435

3536
/* local header */
3637
#include "TestHelper.h"
@@ -51,7 +52,7 @@ namespace vx::TestHelper {
5152
catch ( [[maybe_unused]] const std::exception &_exception ) {
5253

5354
/* nothing to do, file cannot be closed. */
54-
// std::cout << _exception.what() << std::endl;
55+
std::cout << _exception.what() << std::endl;
5556
}
5657
}
5758
return count;

tests/simple/SimpleFileLogger.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ namespace vx {
119119

120120
std::size_t count = TestHelper::countNewLines( tmpFile );
121121

122-
bool removed = std::filesystem::remove( tmpFile );
123-
if ( !removed ) {
122+
if ( !std::filesystem::remove( tmpFile ) ) {
124123

125124
CPPUNIT_FAIL( "Tmp file cannot be removed: " + tmpFile );
126125
}

tests/simple/SimpleXmlLogger.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ namespace vx {
118118

119119
std::size_t count = TestHelper::countNewLines( tmpFile );
120120

121-
bool removed = std::filesystem::remove( tmpFile );
122-
if ( !removed ) {
121+
if ( !std::filesystem::remove( tmpFile ) ) {
123122

124123
CPPUNIT_FAIL( "Tmp file cannot be removed: " + tmpFile );
125124
}

tests/threads/ThreadsFileLogger.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace vx {
110110
threads.reserve( hardwareThreadCount );
111111
for ( unsigned int n = 0; n < hardwareThreadCount; ++n ) {
112112

113-
threads.emplace_back( std::thread( [&] {
113+
threads.emplace_back( std::thread( [&hardwareThreadCount] {
114114

115115
std::ostringstream s;
116116
s << logMessage;
@@ -135,8 +135,7 @@ namespace vx {
135135

136136
std::size_t count = TestHelper::countNewLines( tmpFile );
137137

138-
bool removed = std::filesystem::remove( tmpFile );
139-
if ( !removed ) {
138+
if ( !std::filesystem::remove( tmpFile ) ) {
140139

141140
CPPUNIT_FAIL( "Tmp file cannot be removed: " + tmpFile );
142141
}

tests/threads/ThreadsNullLogger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace vx {
9393
threads.reserve( hardwareThreadCount );
9494
for ( unsigned int n = 0; n < hardwareThreadCount; ++n ) {
9595

96-
threads.emplace_back( std::thread( [&] {
96+
threads.emplace_back( std::thread( [&hardwareThreadCount] {
9797

9898
std::ostringstream s;
9999
s << logMessage;

tests/threads/ThreadsStdLogger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace vx {
9393
threads.reserve( hardwareThreadCount );
9494
for ( unsigned int n = 0; n < hardwareThreadCount; ++n ) {
9595

96-
threads.emplace_back( std::thread( [&] {
96+
threads.emplace_back( std::thread( [&hardwareThreadCount] {
9797

9898
std::ostringstream s;
9999
s << logMessage;

tests/threads/ThreadsXmlLogger.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace vx {
109109
threads.reserve( hardwareThreadCount );
110110
for ( unsigned int n = 0; n < hardwareThreadCount; ++n ) {
111111

112-
threads.emplace_back( std::thread( [&] {
112+
threads.emplace_back( std::thread( [&hardwareThreadCount] {
113113

114114
std::ostringstream s;
115115
s << logMessage;
@@ -134,8 +134,7 @@ namespace vx {
134134

135135
std::size_t count = TestHelper::countNewLines( tmpFile );
136136

137-
bool removed = std::filesystem::remove( tmpFile );
138-
if ( !removed ) {
137+
if ( !std::filesystem::remove( tmpFile ) ) {
139138

140139
CPPUNIT_FAIL( "Tmp file cannot be removed: " + tmpFile );
141140
}

0 commit comments

Comments
 (0)