Skip to content

Mark constructors as explicit to conform to the C++ standard#15

Merged
eljonny merged 3 commits intomainfrom
fix-cppcheck-noexplicitconstructor
Jul 2, 2024
Merged

Mark constructors as explicit to conform to the C++ standard#15
eljonny merged 3 commits intomainfrom
fix-cppcheck-noexplicitconstructor

Conversation

@eljonny
Copy link
Copy Markdown
Owner

@eljonny eljonny commented Jul 2, 2024

These constructors fall into the guideline of constructors that should be marked explicit.
They are converting constructors that are not intended to be used for implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/explicit From that site:
Specifies that a constructor [or conversion function (since C++11)] [or deduction guide (since C++17)] is explicit, that is, it cannot be used for implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/converting_constructor also.

Enable inline CPPCheck suppressions in the GitHub static analysis workflow and the local CPPCheck command in the CodeLite project for suppressing one instance of noExplicitConstructor where it is intended to be used for implicit conversions and copy-initialization.

Add inline suppression to TestCPPUtil.h for noExplicitConstructor.

Add --std=c++11 parameter argument to local CPPCheck check in project. Removed unnecessary ignores from the CPPCheck command arguments where it just needs a clean prior to running the cppcheck custom target because the build system it generated probably includes more than what should be analyzed by CPPCheck.

These constructors fall into the guideline of constructors that should
be marked explicit.
They are converting constructors that are not intended to be used for
implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/explicit
From that site:
Specifies that a constructor [or conversion function (since C++11)] [or
deduction guide (since C++17)] is explicit, that is, it cannot be used
for implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/converting_constructor
also.

Enable inline CPPCheck suppressions in the GitHub static analysis
workflow and the local CPPCheck command in the CodeLite project for
suppressing one instance of noExplicitConstructor where it is intended
to be used for implicit conversions and copy-initialization.

Add inline suppression to TestCPPUtil.h for noExplicitConstructor.

Add --std=c++11 parameter argument to local CPPCheck check in project.
Removed unnecessary ignores from the CPPCheck command arguments where it
just needs a clean prior to running the cppcheck custom target because
the build system it generated probably includes more than what should
be analyzed by CPPCheck.
@eljonny eljonny self-assigned this Jul 2, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.36%. Comparing base (0b25504) to head (36a11c0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #15   +/-   ##
=======================================
  Coverage   77.36%   77.36%           
=======================================
  Files          19       19           
  Lines         561      561           
  Branches       70       70           
=======================================
  Hits          434      434           
  Misses        110      110           
  Partials       17       17           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 2, 2024

⚡ Static analysis result ⚡

🔴 cppcheck found 18 issues! Click here to see details.

string failureMessage = "Arguments are not equivalent!"
)
{
if (expected != actual) {
stringstream err;

!Line: 78 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

string failureMessage = "Arguments are equivalent!"
)
{
if (expected == actual) {
stringstream err;

!Line: 109 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

string failureMessage = "Object is not null!"
)
{
bool null = ptr == nullptr;
if (!null) {

!Line: 136 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

string failureMessage = "Object is null!"
)
{
bool notNull = ptr != nullptr;
if (!notNull) {

!Line: 163 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

string failureMessage
)
{
if (!condition) {
stringstream err;

!Line: 93 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

string failureMessage
)
{
if (condition) {
stringstream err;

!Line: 108 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

bool TestCase::checkStdout (string against) {
return checkOutput(TestCase::stdoutBuffer->str(),
against);
}
bool TestCase::checkLog (string against) {

!Line: 454 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]

bool TestCase::checkLog (string against) {
return checkOutput(TestCase::clogBuffer->str(),
against);
}
bool TestCase::checkStderr (string against) {

!Line: 459 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]

bool TestCase::checkStderr (string against) {
return checkOutput(TestCase::stderrBuffer->str(),
against);
}
bool TestCase::checkOutput (string source, string against)

!Line: 464 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]

bool TestCase::checkOutput (string source, string against)
{
switch (this->option) {
case EXACT:
if (source == against) {
return true;

!Line: 469 - performance: Function parameter 'source' should be passed by const reference. [passedByValue]

bool TestCase::checkOutput (string source, string against)
{
switch (this->option) {
case EXACT:
if (source == against) {
return true;

!Line: 469 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]

TestCase::TestCase (TestCase& o) {
this->outCompareOption(o.option);
this->setNotifyPassed(o.notifyTestPassed);
this->pass = o.pass;
this->lastRunTime = o.lastRunTime;

!Line: 132 - style: Parameter 'o' can be declared as reference to const [constParameterReference]

TestCase& TestCase::operator= (TestCase& rhs) {
this->outCompareOption(rhs.option);
this->setNotifyPassed(rhs.notifyTestPassed);
this->pass = rhs.pass;
this->lastRunTime = rhs.lastRunTime;

!Line: 221 - style: Parameter 'rhs' can be declared as reference to const [constParameterReference]

void TestCase::logFailure(ostream& out, string& reason) {
out << fixed;
out << setprecision(TCPPNum::TIME_PRECISION);
out << TCPPStr::TEST_ << this->testName << TCPPStr::_FAIL_
<< TCPPStr::PARENL
<< static_cast<double>(this->lastRunTime)/

!Line: 279 - style: Parameter 'reason' can be declared as reference to const [constParameterReference]

TestSuite (TestObjName&& suiteName,
typename enable_if<sizeof...(TestType) == 0>::type)
{
this->testSuitePassedMessage = true;
this->setSuiteName(move(suiteName));
this->tests = vector<TestCase>();

!Line: 81 - warning: Member variable 'TestSuite::lastRunSucceeded' is not initialized in the constructor. [uninitMemberVar]

TestSuite (TestObjName&& suiteName,
typename enable_if<sizeof...(TestType) == 0>::type)
{
this->testSuitePassedMessage = true;
this->setSuiteName(move(suiteName));
this->tests = vector<TestCase>();

!Line: 81 - warning: Member variable 'TestSuite::lastRunSuccessCount' is not initialized in the constructor. [uninitMemberVar]

TestSuite (TestObjName&& suiteName,
typename enable_if<sizeof...(TestType) == 0>::type)
{
this->testSuitePassedMessage = true;
this->setSuiteName(move(suiteName));
this->tests = vector<TestCase>();

!Line: 81 - warning: Member variable 'TestSuite::lastRunFailCount' is not initialized in the constructor. [uninitMemberVar]

TestSuite (TestObjName&& suiteName,
typename enable_if<sizeof...(TestType) == 0>::type)
{
this->testSuitePassedMessage = true;
this->setSuiteName(move(suiteName));
this->tests = vector<TestCase>();

!Line: 81 - warning: Member variable 'TestSuite::totalRuntime' is not initialized in the constructor. [uninitMemberVar]


🔴 clang-tidy found 149 issues! Click here to see details.

using std::clog;
using std::move;
using std::string;
using std::runtime_error;
namespace TestCPP {

!Line: 36 - warning: using decl 'clog' is unused [misc-unused-using-decls]

!Line: 36 - note: remove the using

using std::string;
using std::runtime_error;
namespace TestCPP {
TestCPPException::TestCPPException (const char * msg) :

!Line: 38 - warning: no header providing "std::string" is directly included [misc-include-cleaner]

using std::runtime_error;
namespace TestCPP {
TestCPPException::TestCPPException (const char * msg) :
runtime_error(msg)

!Line: 39 - warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]

runtime_error(move(msg))
{
#ifdef TESTCPP_STACKTRACE_ENABLED
clog << boost::stacktrace::stacktrace();
#endif
}

!Line: 51 - warning: passing result of std::move() as a const reference argument; no move will actually happen [hicpp-move-const-arg,performance-move-const-arg]

if (name) {
this->testCaseName = name;
}
else {
throw TestCPPException(TCPPStr::NVTN);
}

!Line: 51 - warning: implicit conversion 'const char *' -> 'bool' [readability-implicit-bool-conversion]

const string& TestObjName::getName () {
return this->testCaseName;
}
std::ostream& operator<< (
std::ostream& s,

!Line: 59 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

std::ostream& operator<< (
std::ostream& s,
TestObjName& tcName
)
{
s << tcName.getName();

!Line: 63 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

std::ostream& s,
TestObjName& tcName
)
{
s << tcName.getName();
return s;

!Line: 64 - warning: parameter name 's' is too short, expected at least 3 characters [readability-identifier-length]

clog << endl;
}
#endif
}
bool stringContains(const string& source,

!Line: 78 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

bool stringContains(const string& source,
const string& contains)
{
return source.find(contains) != string::npos;
}

!Line: 83 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

int unsignedToSigned(unsigned toCast) {
if (toCast <= INT_MAX) {
return static_cast<int>(toCast);
}
if (toCast >= static_cast<unsigned>(INT_MIN)) {

!Line: 89 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

using std::clog;
using std::current_exception;
using std::endl;
using std::exception;
using std::exception_ptr;
using std::function;

!Line: 30 - warning: no header providing "std::clog" is directly included [misc-include-cleaner]

using std::current_exception;
using std::endl;
using std::exception;
using std::exception_ptr;
using std::function;
using std::move;

!Line: 31 - warning: no header providing "std::current_exception" is directly included [misc-include-cleaner]

using std::exception;
using std::exception_ptr;
using std::function;
using std::move;
using std::rethrow_exception;
using std::string;

!Line: 33 - warning: no header providing "std::exception" is directly included [misc-include-cleaner]

using std::exception_ptr;
using std::function;
using std::move;
using std::rethrow_exception;
using std::string;
using std::stringstream;

!Line: 34 - warning: no header providing "std::__exception_ptr::exception_ptr" is directly included [misc-include-cleaner]

using std::rethrow_exception;
using std::string;
using std::stringstream;
namespace TestCPP {

!Line: 37 - warning: no header providing "std::rethrow_exception" is directly included [misc-include-cleaner]

using std::string;
using std::stringstream;
namespace TestCPP {
void Assertions::assertThrows (

!Line: 38 - warning: no header providing "std::string" is directly included [misc-include-cleaner]

using std::stringstream;
namespace TestCPP {
void Assertions::assertThrows (
function<void()> shouldThrow,

!Line: 39 - warning: no header providing "std::stringstream" is directly included [misc-include-cleaner]

function<void()> shouldThrow,
string failureMessage
)
{
try {
shouldThrow();

!Line: 44 - warning: the parameter 'shouldThrow' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

exception_ptr eptr = current_exception();
if (eptr) {
try {
rethrow_exception(eptr);
}

!Line: 52 - warning: variable 'eptr' of type 'exception_ptr' can be declared 'const' [misc-const-correctness]

<< endl;
}
}
else {
clog << "Something was thrown, not sure what." << endl
<< "This satisfies the assertion, so no failure is"

!Line: 61 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

clog << "Something was thrown, not sure what." << endl
<< "This satisfies the assertion, so no failure is"
<< " present. "
<< TestFailedException("Unknown thrown object").
what();
}

!Line: 65 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

function<void()> shouldNotThrow,
string failureMessage
)
{
try {
shouldNotThrow();

!Line: 79 - warning: the parameter 'shouldNotThrow' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

string failureMessage
)
{
if (!condition) {
stringstream err;

!Line: 93 - warning: the parameter 'failureMessage' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

err << "Boolean Truth assertion failed!" << endl;
err << failureMessage << endl;
throw TestFailedException(err.str());
}
}

!Line: 99 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

err << failureMessage << endl;
throw TestFailedException(err.str());
}
}

!Line: 100 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

string failureMessage
)
{
if (condition) {
stringstream err;

!Line: 108 - warning: the parameter 'failureMessage' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

err << "Boolean False assertion failed!" << endl;
err << failureMessage << endl;
throw TestFailedException(err.str());
}
}

!Line: 114 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

err << failureMessage << endl;
throw TestFailedException(err.str());
}
}

!Line: 115 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

using std::cerr;
using std::clog;
using std::cout;
using std::endl;
using std::exception;
using std::fixed;

!Line: 36 - warning: no header providing "std::cerr" is directly included [misc-include-cleaner]

using std::clog;
using std::cout;
using std::endl;
using std::exception;
using std::fixed;
using std::function;

!Line: 37 - warning: no header providing "std::clog" is directly included [misc-include-cleaner]

using std::cout;
using std::endl;
using std::exception;
using std::fixed;
using std::function;
using std::invalid_argument;

!Line: 38 - warning: using decl 'cout' is unused [misc-unused-using-decls]

!Line: 38 - note: remove the using

using std::exception;
using std::fixed;
using std::function;
using std::invalid_argument;
using std::move;
using std::ostream;

!Line: 40 - warning: no header providing "std::exception" is directly included [misc-include-cleaner]

using std::fixed;
using std::function;
using std::invalid_argument;
using std::move;
using std::ostream;
using std::rethrow_exception;

!Line: 41 - warning: no header providing "std::fixed" is directly included [misc-include-cleaner]

using std::invalid_argument;
using std::move;
using std::ostream;
using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;

!Line: 43 - warning: using decl 'invalid_argument' is unused [misc-unused-using-decls]

!Line: 43 - note: remove the using

using std::ostream;
using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;

!Line: 45 - warning: no header providing "std::ostream" is directly included [misc-include-cleaner]

using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;

!Line: 46 - warning: no header providing "std::rethrow_exception" is directly included [misc-include-cleaner]

using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;

!Line: 46 - warning: using decl 'rethrow_exception' is unused [misc-unused-using-decls]

!Line: 46 - note: remove the using

using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;

!Line: 47 - warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]

using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;

!Line: 47 - warning: using decl 'runtime_error' is unused [misc-unused-using-decls]

!Line: 47 - note: remove the using

using std::string;
using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;
using TCPPStr = TestCPP::TestCPPCommon::Strings;

!Line: 49 - warning: no header providing "std::string" is directly included [misc-include-cleaner]

void TestSuite::setSuiteName (TestObjName&& testSuiteName) {
this->suiteName = move(testSuiteName);
}
unsigned TestSuite::getLastRunFailCount () {
return this->lastRunFailCount;

!Line: 70 - warning: no header providing "TestCPP::TestObjName" is directly included [misc-include-cleaner]

unsigned TestSuite::getLastRunFailCount () {
return this->lastRunFailCount;
}
void TestSuite::run () {
if (this->tests.size() == 0) {

!Line: 74 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

unsigned TestSuite::getLastRunFailCount () {
return this->lastRunFailCount;
}
void TestSuite::run () {
if (this->tests.size() == 0) {

!Line: 74 - warning: method 'getLastRunFailCount' can be made const [readability-make-member-function-const]

if (this->tests.size() == 0) {
clog << TCPPStr::NTR << endl;
return;
}
this->lastRunSucceeded = true;

!Line: 79 - warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]

clog << TCPPStr::NTR << endl;
return;
}
this->lastRunSucceeded = true;
this->lastRunFailCount = 0;

!Line: 80 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

clog << endl
<< TCPPStr::START_RUN << TCPPStr::SUITE_
<< TCPPStr::APOS << this->suiteName << TCPPStr::APOS
<< endl
<< endl;

!Line: 89 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

<< endl
<< endl;
for (TestCase test : this->tests) {
bool testPassed = false;
try {

!Line: 92 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

<< endl;
for (TestCase test : this->tests) {
bool testPassed = false;
try {
testPassed = test.go();

!Line: 93 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

<< endl;
}
catch (...) {
cerr << TCPPStr::UNK_EXC
<< endl;
}

!Line: 102 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

<< endl;
}
if (!testPassed) {
this->lastRunFailCount++;

!Line: 106 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

clog << endl;
if (this->testSuitePassedMessage &&
this->lastRunFailCount == 0) {
clog << TCPPStr::ALL_ << TCPPStr::APOS << this->suiteName
<< TCPPStr::APOS << TCPPStr::_SUITE_TESTS_PASSED

!Line: 123 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

<< endl;
}
double suiteRuntimeElapsed = static_cast<double>(
this->totalRuntime)/TCPPNum::NANOS_IN_SEC;

!Line: 129 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

double suiteRuntimeElapsed = static_cast<double>(
this->totalRuntime)/TCPPNum::NANOS_IN_SEC;
clog << fixed;
clog << setprecision(0);
clog << TCPPStr::FINISHED_SUITE_ << TCPPStr::APOS

!Line: 132 - warning: variable 'suiteRuntimeElapsed' of type 'double' can be declared 'const' [misc-const-correctness]

<< endl;
}
/**
* @brief Add a test to this test suite.
*

!Line: 143 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

void TestSuite::addTest (TestCase&& test) {
this->tests.emplace_back(test);
}
/**
* @brief Add a test to this test suite.

!Line: 152 - warning: rvalue reference parameter 'test' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]

function<void()>>&& test) {
this->tests.emplace_back(
std::get<0>(test),
std::get<1>(test),
this->testSuitePassedMessage
);

!Line: 165 - warning: rvalue reference parameter 'test' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]

TestCase (
TestObjName&& testName,
function<void()> test,
bool testPassedMessage = true,
bool captureOut = false,
bool captureLog = false,

!Line: 131 - warning: function 'TestCPP::TestCase::TestCase' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]

!Line: 101 - note: the definition seen here
!Line: 131 - note: differing parameters are named here: ('testPassedMessage'), in definition: ('msg')

void logTestFailure (string failureMessage);
/**
* @brief Internal test run controller.
*/
void runTest ();
/**

!Line: 299 - warning: function 'TestCPP::TestCase::logTestFailure' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]

!Line: 291 - note: the definition seen here
!Line: 299 - note: differing parameters are named here: ('failureMessage'), in definition: ('reason')

using std::cerr;
using std::clog;
using std::cout;
using std::endl;
using std::exception;
using std::fixed;

!Line: 43 - warning: no header providing "std::cerr" is directly included [misc-include-cleaner]

using std::clog;
using std::cout;
using std::endl;
using std::exception;
using std::fixed;
using std::function;

!Line: 44 - warning: no header providing "std::clog" is directly included [misc-include-cleaner]

using std::cout;
using std::endl;
using std::exception;
using std::fixed;
using std::function;
using std::invalid_argument;

!Line: 45 - warning: no header providing "std::cout" is directly included [misc-include-cleaner]

using std::exception;
using std::fixed;
using std::function;
using std::invalid_argument;
using std::move;
using std::rethrow_exception;

!Line: 47 - warning: no header providing "std::exception" is directly included [misc-include-cleaner]

using std::fixed;
using std::function;
using std::invalid_argument;
using std::move;
using std::rethrow_exception;
using std::runtime_error;

!Line: 48 - warning: no header providing "std::fixed" is directly included [misc-include-cleaner]

using std::invalid_argument;
using std::move;
using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;
using std::string;

!Line: 50 - warning: using decl 'invalid_argument' is unused [misc-unused-using-decls]

!Line: 50 - note: remove the using

using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;

!Line: 52 - warning: no header providing "std::rethrow_exception" is directly included [misc-include-cleaner]

using std::rethrow_exception;
using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;

!Line: 52 - warning: using decl 'rethrow_exception' is unused [misc-unused-using-decls]

!Line: 52 - note: remove the using

using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;

!Line: 53 - warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]

using std::runtime_error;
using std::setprecision;
using std::string;
using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;

!Line: 53 - warning: using decl 'runtime_error' is unused [misc-unused-using-decls]

!Line: 53 - note: remove the using

using std::string;
using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;
using TCPPStr = TestCPP::TestCPPCommon::Strings;

!Line: 55 - warning: no header providing "std::string" is directly included [misc-include-cleaner]

using std::tuple;
using TCPPNum = TestCPP::TestCPPCommon::Nums;
using TCPPStr = TestCPP::TestCPPCommon::Strings;
namespace TestCPP {

!Line: 56 - warning: using decl 'tuple' is unused [misc-unused-using-decls]

!Line: 56 - note: remove the using

atomic_int TestCase::stdoutCaptureCasesConstructed;
atomic_int TestCase::logCaptureCasesConstructed;
atomic_int TestCase::stderrCaptureCasesConstructed;
atomic_int TestCase::stdoutCaptureCasesDestroyed;
atomic_int TestCase::logCaptureCasesDestroyed;
atomic_int TestCase::stderrCaptureCasesDestroyed;

!Line: 63 - warning: no header providing "atomic_int" is directly included [misc-include-cleaner]

TestCase::TestCase (TestObjName&& name,
function<void()> test,
bool msg,
bool captureOut, bool captureLog,
bool captureErr,
TestCase::TestCaseOutCompareOptions opt)

!Line: 101 - warning: rvalue reference parameter 'name' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]

this->notifyTestPassed = msg;
this->test = test;
this->testName = name;
if (captureOut) {

!Line: 108 - warning: 'notifyTestPassed' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->test = test;
this->testName = name;
if (captureOut) {
captureStdout();

!Line: 109 - warning: 'test' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->test = test;
this->testName = name;
if (captureOut) {
captureStdout();

!Line: 109 - warning: parameter 'test' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]

this->testName = name;
if (captureOut) {
captureStdout();
}
if (captureLog) {

!Line: 111 - warning: 'testName' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

TestCase::TestCase (TestCase& o) {
this->outCompareOption(o.option);
this->setNotifyPassed(o.notifyTestPassed);
this->pass = o.pass;
this->lastRunTime = o.lastRunTime;

!Line: 132 - warning: parameter name 'o' is too short, expected at least 3 characters [readability-identifier-length]

this->pass = o.pass;
this->lastRunTime = o.lastRunTime;
this->stdoutCaptured = o.stdoutCaptured;
this->clogCaptured = o.clogCaptured;
this->stderrCaptured = o.stderrCaptured;

!Line: 136 - warning: 'pass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->lastRunTime = o.lastRunTime;
this->stdoutCaptured = o.stdoutCaptured;
this->clogCaptured = o.clogCaptured;
this->stderrCaptured = o.stderrCaptured;

!Line: 137 - warning: 'lastRunTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->stdoutCaptured = o.stdoutCaptured;
this->clogCaptured = o.clogCaptured;
this->stderrCaptured = o.stderrCaptured;
if (this->stdoutCaptured) {
captureStdout();

!Line: 139 - warning: 'stdoutCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->clogCaptured = o.clogCaptured;
this->stderrCaptured = o.stderrCaptured;
if (this->stdoutCaptured) {
captureStdout();
}

!Line: 140 - warning: 'clogCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->stderrCaptured = o.stderrCaptured;
if (this->stdoutCaptured) {
captureStdout();
}
if (this->clogCaptured) {

!Line: 141 - warning: 'stderrCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

TestCase::TestCase (TestCase&& o) {
this->outCompareOption(move(o.option));
this->setNotifyPassed(move(o.notifyTestPassed));
this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);

!Line: 157 - warning: an exception may be thrown in function 'TestCase' which should not throw exceptions [bugprone-exception-escape]

TestCase::TestCase (TestCase&& o) {
this->outCompareOption(move(o.option));
this->setNotifyPassed(move(o.notifyTestPassed));
this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);

!Line: 157 - warning: move constructors should be marked noexcept [cppcoreguidelines-noexcept-move-operations,hicpp-noexcept-move,performance-noexcept-move-constructor]

TestCase::TestCase (TestCase&& o) {
this->outCompareOption(move(o.option));
this->setNotifyPassed(move(o.notifyTestPassed));
this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);

!Line: 157 - warning: parameter name 'o' is too short, expected at least 3 characters [readability-identifier-length]

this->outCompareOption(move(o.option));
this->setNotifyPassed(move(o.notifyTestPassed));
this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);

!Line: 158 - warning: std::move of the expression of the trivially-copyable type 'TestCaseOutCompareOptions' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->setNotifyPassed(move(o.notifyTestPassed));
this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);
this->stdoutCaptured = move(o.stdoutCaptured);

!Line: 159 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);
this->stdoutCaptured = move(o.stdoutCaptured);
this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);

!Line: 161 - warning: 'pass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->pass = move(o.pass);
this->lastRunTime = move(o.lastRunTime);
this->stdoutCaptured = move(o.stdoutCaptured);
this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);

!Line: 161 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->lastRunTime = move(o.lastRunTime);
this->stdoutCaptured = move(o.stdoutCaptured);
this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);

!Line: 162 - warning: 'lastRunTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->lastRunTime = move(o.lastRunTime);
this->stdoutCaptured = move(o.stdoutCaptured);
this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);

!Line: 162 - warning: std::move of the expression of the trivially-copyable type 'long long' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->stdoutCaptured = move(o.stdoutCaptured);
this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();

!Line: 164 - warning: 'stdoutCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->stdoutCaptured = move(o.stdoutCaptured);
this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();

!Line: 164 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();
}

!Line: 165 - warning: 'clogCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->clogCaptured = move(o.clogCaptured);
this->stderrCaptured = move(o.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();
}

!Line: 165 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->stderrCaptured = move(o.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();
}
if (this->clogCaptured) {

!Line: 166 - warning: 'stderrCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

this->stderrCaptured = move(o.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();
}
if (this->clogCaptured) {

!Line: 166 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

delete TestCase::stdoutBuffer.get();
TestCase::stdoutBuffer = nullptr;
}
TestCase::stdoutCaptureCasesDestroyed += 1;
}

!Line: 189 - warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

!Line: 70 - note: variable declared here

delete TestCase::clogBuffer.get();
TestCase::clogBuffer = nullptr;
}
TestCase::logCaptureCasesDestroyed += 1;
}

!Line: 201 - warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

!Line: 75 - note: variable declared here

delete TestCase::stderrBuffer.get();
TestCase::stderrBuffer = nullptr;
}
TestCase::stderrCaptureCasesDestroyed += 1;
}

!Line: 213 - warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

!Line: 80 - note: variable declared here

TestCase& TestCase::operator= (TestCase& rhs) {
this->outCompareOption(rhs.option);
this->setNotifyPassed(rhs.notifyTestPassed);
this->pass = rhs.pass;
this->lastRunTime = rhs.lastRunTime;

!Line: 221 - warning: operator=() should take 'TestCase const&', 'TestCase&&' or 'TestCase' [cppcoreguidelines-c-copy-assignment-signature,misc-unconventional-assign-operator]

TestCase& TestCase::operator= (TestCase& rhs) {
this->outCompareOption(rhs.option);
this->setNotifyPassed(rhs.notifyTestPassed);
this->pass = rhs.pass;
this->lastRunTime = rhs.lastRunTime;

!Line: 221 - warning: operator=() does not handle self-assignment properly [cert-oop54-cpp]

TestCase& TestCase::operator= (TestCase& rhs) {
this->outCompareOption(rhs.option);
this->setNotifyPassed(rhs.notifyTestPassed);
this->pass = rhs.pass;
this->lastRunTime = rhs.lastRunTime;

!Line: 221 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

TestCase& TestCase::operator= (TestCase&& rhs) {
this->outCompareOption(move(rhs.option));
this->setNotifyPassed(move(rhs.notifyTestPassed));
this->pass = move(rhs.pass);
this->lastRunTime = move(rhs.lastRunTime);

!Line: 248 - warning: an exception may be thrown in function 'operator=' which should not throw exceptions [bugprone-exception-escape]

TestCase& TestCase::operator= (TestCase&& rhs) {
this->outCompareOption(move(rhs.option));
this->setNotifyPassed(move(rhs.notifyTestPassed));
this->pass = move(rhs.pass);
this->lastRunTime = move(rhs.lastRunTime);

!Line: 248 - warning: move assignment operators should be marked noexcept [cppcoreguidelines-noexcept-move-operations,hicpp-noexcept-move,performance-noexcept-move-constructor]

TestCase& TestCase::operator= (TestCase&& rhs) {
this->outCompareOption(move(rhs.option));
this->setNotifyPassed(move(rhs.notifyTestPassed));
this->pass = move(rhs.pass);
this->lastRunTime = move(rhs.lastRunTime);

!Line: 248 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

this->outCompareOption(move(rhs.option));
this->setNotifyPassed(move(rhs.notifyTestPassed));
this->pass = move(rhs.pass);
this->lastRunTime = move(rhs.lastRunTime);

!Line: 249 - warning: std::move of the expression of the trivially-copyable type 'TestCaseOutCompareOptions' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->setNotifyPassed(move(rhs.notifyTestPassed));
this->pass = move(rhs.pass);
this->lastRunTime = move(rhs.lastRunTime);
this->stdoutCaptured = move(rhs.stdoutCaptured);

!Line: 250 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->pass = move(rhs.pass);
this->lastRunTime = move(rhs.lastRunTime);
this->stdoutCaptured = move(rhs.stdoutCaptured);
this->clogCaptured = move(rhs.clogCaptured);
this->stderrCaptured = move(rhs.stderrCaptured);

!Line: 252 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->lastRunTime = move(rhs.lastRunTime);
this->stdoutCaptured = move(rhs.stdoutCaptured);
this->clogCaptured = move(rhs.clogCaptured);
this->stderrCaptured = move(rhs.stderrCaptured);

!Line: 253 - warning: std::move of the expression of the trivially-copyable type 'long long' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->stdoutCaptured = move(rhs.stdoutCaptured);
this->clogCaptured = move(rhs.clogCaptured);
this->stderrCaptured = move(rhs.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();

!Line: 255 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->clogCaptured = move(rhs.clogCaptured);
this->stderrCaptured = move(rhs.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();
}

!Line: 256 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

this->stderrCaptured = move(rhs.stderrCaptured);
if (this->stdoutCaptured) {
captureStdout();
}
if (this->clogCaptured) {

!Line: 257 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]

long long TestCase::getLastRuntime () {
return this->lastRunTime;
}
void TestCase::logFailure(ostream& out, string& reason) {
out << fixed;

!Line: 275 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

long long TestCase::getLastRuntime () {
return this->lastRunTime;
}
void TestCase::logFailure(ostream& out, string& reason) {
out << fixed;

!Line: 275 - warning: method 'getLastRuntime' can be made const [readability-make-member-function-const]

<< endl;
out << TCPPStr::REASON_ << reason << endl;
}
void TestCase::logTestFailure (string reason) {
unique_ptr<ostream> logStream = nullptr;

!Line: 287 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

out << TCPPStr::REASON_ << reason << endl;
}
void TestCase::logTestFailure (string reason) {
unique_ptr<ostream> logStream = nullptr;

!Line: 288 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

if (this->clogOriginal != nullptr) {
logStream = unique_ptr<ostream>(
new ostream(this->clogOriginal.get())
);
}
else {

!Line: 294 - warning: static member accessed through instance [readability-static-accessed-through-instance]

new ostream(this->clogOriginal.get())
);
}
else {
logStream = unique_ptr<ostream>(&clog);
}

!Line: 296 - warning: static member accessed through instance [readability-static-accessed-through-instance]

if (this->clogOriginal != nullptr) {
logStream->flush();
// If someone is looking for something in the message,
// and it's captured, make sure it's there.
logFailure(clog, reason);

!Line: 305 - warning: static member accessed through instance [readability-static-accessed-through-instance]

logStream.release();
logStream.reset();
}
void TestCase::runTest () {
clog << TCPPStr::START_RUN << this->testName << endl;

!Line: 313 - warning: the value returned by this function should not be disregarded; neglecting it may lead to errors [bugprone-unused-return-value]

clog << TCPPStr::START_RUN << this->testName << endl;
this->lastRunTime = duration(this->test).count();
if (this->notifyTestPassed) {
clog << fixed;
clog << setprecision(TCPPNum::TIME_PRECISION);
clog << TCPPStr::TEST_ << this->testName << TCPPStr::_PASS_

!Line: 318 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

<< endl;
}
this->pass = true;
}
bool TestCase::go () {

!Line: 328 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

bool TestCase::go () {
try {
runTest();
return true;
}
catch(const char * errorMessage) {

!Line: 333 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

void TestCase::captureStdout () {
if (TestCase::stdoutCaptureCasesConstructed ==
TestCase::stdoutCaptureCasesDestroyed)
{
TestCase::stdoutCaptureCasesConstructed += 1;
TestCase::stdoutBuffer =

!Line: 362 - warning: method 'captureStdout' can be made static [readability-convert-member-functions-to-static]

void TestCase::captureClog () {
if (TestCase::logCaptureCasesConstructed ==
TestCase::logCaptureCasesDestroyed)
{
TestCase::logCaptureCasesConstructed += 1;
TestCase::clogBuffer =

!Line: 382 - warning: method 'captureClog' can be made static [readability-convert-member-functions-to-static]

void TestCase::captureStdErr () {
if (TestCase::stderrCaptureCasesConstructed ==
TestCase::stderrCaptureCasesDestroyed)
{
TestCase::stderrCaptureCasesConstructed += 1;
TestCase::stderrBuffer =

!Line: 402 - warning: method 'captureStdErr' can be made static [readability-convert-member-functions-to-static]

void TestCase::clearStdoutCapture () {
if (TestCase::stdoutBuffer) {
TestCase::stdoutBuffer->str(string());
}
}

!Line: 436 - warning: method 'clearStdoutCapture' can be made static [readability-convert-member-functions-to-static]

void TestCase::clearLogCapture () {
if (TestCase::clogBuffer) {
TestCase::clogBuffer->str(string());
}
}

!Line: 442 - warning: method 'clearLogCapture' can be made static [readability-convert-member-functions-to-static]

void TestCase::clearStderrCapture () {
if (TestCase::stderrBuffer) {
TestCase::stderrBuffer->str(string());
}
}

!Line: 448 - warning: method 'clearStderrCapture' can be made static [readability-convert-member-functions-to-static]

bool TestCase::checkStdout (string against) {
return checkOutput(TestCase::stdoutBuffer->str(),
against);
}
bool TestCase::checkLog (string against) {

!Line: 454 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

against);
}
bool TestCase::checkLog (string against) {
return checkOutput(TestCase::clogBuffer->str(),
against);

!Line: 456 - warning: parameter 'against' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]

bool TestCase::checkLog (string against) {
return checkOutput(TestCase::clogBuffer->str(),
against);
}
bool TestCase::checkStderr (string against) {

!Line: 459 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

against);
}
bool TestCase::checkStderr (string against) {
return checkOutput(TestCase::stderrBuffer->str(),
against);

!Line: 461 - warning: parameter 'against' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]

bool TestCase::checkStderr (string against) {
return checkOutput(TestCase::stderrBuffer->str(),
against);
}
bool TestCase::checkOutput (string source, string against)

!Line: 464 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

against);
}
bool TestCase::checkOutput (string source, string against)
{
switch (this->option) {

!Line: 466 - warning: parameter 'against' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]

bool TestCase::checkOutput (string source, string against)
{
switch (this->option) {
case EXACT:
if (source == against) {
return true;

!Line: 469 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]

bool TestCase::checkOutput (string source, string against)
{
switch (this->option) {
case EXACT:
if (source == against) {
return true;

!Line: 469 - warning: the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

bool TestCase::checkOutput (string source, string against)
{
switch (this->option) {
case EXACT:
if (source == against) {
return true;

!Line: 469 - warning: the parameter 'against' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

if (this->clogOriginal != nullptr) {
ostream tmp(this->clogOriginal.get());
tmp << nomatch.str() << endl;
tmp.flush();
}
else {

!Line: 482 - warning: static member accessed through instance [readability-static-accessed-through-instance]

ostream tmp(this->clogOriginal.get());
tmp << nomatch.str() << endl;
tmp.flush();
}
else {
clog << nomatch.str() << endl;

!Line: 483 - warning: static member accessed through instance [readability-static-accessed-through-instance]

tmp << nomatch.str() << endl;
tmp.flush();
}
else {
clog << nomatch.str() << endl;
}

!Line: 484 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

clog << nomatch.str() << endl;
}
return false;
}

!Line: 488 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

if (this->clogOriginal != nullptr) {
ostream tmp(this->clogOriginal.get());
tmp << nomatch.str() << endl;
tmp.flush();
}
else {

!Line: 504 - warning: static member accessed through instance [readability-static-accessed-through-instance]

ostream tmp(this->clogOriginal.get());
tmp << nomatch.str() << endl;
tmp.flush();
}
else {
clog << nomatch.str() << endl;

!Line: 505 - warning: static member accessed through instance [readability-static-accessed-through-instance]

tmp << nomatch.str() << endl;
tmp.flush();
}
else {
clog << nomatch.str() << endl;
}

!Line: 506 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

clog << nomatch.str() << endl;
}
return false;
}

!Line: 510 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]

stringstream re;
re << TCPPStr::UNK_CMP_OPT_ << this->option;
throw TestCPPException(re.str());
}
}
}

!Line: 517 - warning: variable name 're' is too short, expected at least 3 characters [readability-identifier-length]


@eljonny eljonny linked an issue Jul 2, 2024 that may be closed by this pull request
@eljonny
Copy link
Copy Markdown
Owner Author

eljonny commented Jul 2, 2024

CPPCheck warnings/violations addressed by this PR via #6 are verified fixed.

@eljonny eljonny merged commit 8f91d8a into main Jul 2, 2024
@eljonny eljonny deleted the fix-cppcheck-noexplicitconstructor branch July 2, 2024 03:04
eljonny added a commit that referenced this pull request Feb 18, 2025
* Mark constructors as explicit to conform to the C++ standard

These constructors fall into the guideline of constructors that should
be marked explicit.
They are converting constructors that are not intended to be used for
implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/explicit
From that site:
Specifies that a constructor [or conversion function (since C++11)] [or
deduction guide (since C++17)] is explicit, that is, it cannot be used
for implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/converting_constructor
also.

Enable inline CPPCheck suppressions in the GitHub static analysis
workflow and the local CPPCheck command in the CodeLite project for
suppressing one instance of noExplicitConstructor where it is intended
to be used for implicit conversions and copy-initialization.

Add inline suppression to TestCPPUtil.h for noExplicitConstructor.

Add --std=c++11 parameter argument to local CPPCheck check in project.
Removed unnecessary ignores from the CPPCheck command arguments where it
just needs a clean prior to running the cppcheck custom target because
the build system it generated probably includes more than what should
be analyzed by CPPCheck.

* Moved this change to main
eljonny added a commit that referenced this pull request Feb 18, 2025
* Mark constructors as explicit to conform to the C++ standard

These constructors fall into the guideline of constructors that should
be marked explicit.
They are converting constructors that are not intended to be used for
implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/explicit
From that site:
Specifies that a constructor [or conversion function (since C++11)] [or
deduction guide (since C++17)] is explicit, that is, it cannot be used
for implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/converting_constructor
also.

Enable inline CPPCheck suppressions in the GitHub static analysis
workflow and the local CPPCheck command in the CodeLite project for
suppressing one instance of noExplicitConstructor where it is intended
to be used for implicit conversions and copy-initialization.

Add inline suppression to TestCPPUtil.h for noExplicitConstructor.

Add --std=c++11 parameter argument to local CPPCheck check in project.
Removed unnecessary ignores from the CPPCheck command arguments where it
just needs a clean prior to running the cppcheck custom target because
the build system it generated probably includes more than what should
be analyzed by CPPCheck.

* Moved this change to main
eljonny added a commit that referenced this pull request Feb 18, 2025
* Mark constructors as explicit to conform to the C++ standard

These constructors fall into the guideline of constructors that should
be marked explicit.
They are converting constructors that are not intended to be used for
implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/explicit
From that site:
Specifies that a constructor [or conversion function (since C++11)] [or
deduction guide (since C++17)] is explicit, that is, it cannot be used
for implicit conversions and copy-initialization.

See https://en.cppreference.com/w/cpp/language/converting_constructor
also.

Enable inline CPPCheck suppressions in the GitHub static analysis
workflow and the local CPPCheck command in the CodeLite project for
suppressing one instance of noExplicitConstructor where it is intended
to be used for implicit conversions and copy-initialization.

Add inline suppression to TestCPPUtil.h for noExplicitConstructor.

Add --std=c++11 parameter argument to local CPPCheck check in project.
Removed unnecessary ignores from the CPPCheck command arguments where it
just needs a clean prior to running the cppcheck custom target because
the build system it generated probably includes more than what should
be analyzed by CPPCheck.

* Moved this change to main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix CPPCheck issues - non-explicit constructors

1 participant