Skip to content

Conversation

eljonny
Copy link
Owner

@eljonny eljonny commented Feb 19, 2025

Use the updated marketplace action that I just published that uses the updated container with clang-19.

Use the updated marketplace action that I just published that uses the updated container with clang-19.
@eljonny eljonny merged commit cd5672c into fix-cppcheck-uninitmembervar Feb 19, 2025
32 of 34 checks passed
Copy link

⚡ Static analysis result ⚡

🔴 cppcheck found 32 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: 92 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]

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

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

void clearStdoutCapture ();
/**
* @brief Clears the captured output from std::clog.
*
* This can be used for checking sections of output based on

!Line: 199 - performance: inconclusive: Technically the member function 'TestCPP::TestCase::clearStdoutCapture' can be static (but you may consider moving to unnamed namespace). [functionStatic]

!Line: 461 - note: Technically the member function 'TestCPP::TestCase::clearStdoutCapture' can be static (but you may consider moving to unnamed namespace).
!Line: 199 - note: Technically the member function 'TestCPP::TestCase::clearStdoutCapture' can be static (but you may consider moving to unnamed namespace).

void clearLogCapture ();
/**
* @brief Clears the captured output from stderr.
*
* This can be used for checking sections of output based on

!Line: 207 - performance: inconclusive: Technically the member function 'TestCPP::TestCase::clearLogCapture' can be static (but you may consider moving to unnamed namespace). [functionStatic]

!Line: 467 - note: Technically the member function 'TestCPP::TestCase::clearLogCapture' can be static (but you may consider moving to unnamed namespace).
!Line: 207 - note: Technically the member function 'TestCPP::TestCase::clearLogCapture' can be static (but you may consider moving to unnamed namespace).

void clearStderrCapture ();
/**
* @brief Check the argument against what is captured from
* stdout using the configured comparison mode.
* @param against The value to check the captured output against

!Line: 215 - performance: inconclusive: Technically the member function 'TestCPP::TestCase::clearStderrCapture' can be static (but you may consider moving to unnamed namespace). [functionStatic]

!Line: 473 - note: Technically the member function 'TestCPP::TestCase::clearStderrCapture' can be static (but you may consider moving to unnamed namespace).
!Line: 215 - note: Technically the member function 'TestCPP::TestCase::clearStderrCapture' can be static (but you may consider moving to unnamed namespace).

void logFailure (ostream& out, string& reason);
/**
* @brief If a test encounters an error while running, this
* function will be called to log the test error.
* @param failureMessage The error message from the test that
* should be logged.

!Line: 292 - style: inconclusive: Technically the member function 'TestCPP::TestCase::logFailure' can be const. [functionConst]

!Line: 292 - note: Technically the member function 'TestCPP::TestCase::logFailure' can be const.
!Line: 292 - note: Technically the member function 'TestCPP::TestCase::logFailure' can be const.

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

!Line: 171 - error: Exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]

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

!Line: 262 - error: Exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]

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

!Line: 114 - style: inconclusive: Function 'TestCase' argument 1 names different: declaration 'testName' definition 'name'. [funcArgNamesDifferent]

!Line: 132 - note: Function 'TestCase' argument 1 names different: declaration 'testName' definition 'name'.
!Line: 114 - note: Function 'TestCase' argument 1 names different: declaration 'testName' definition 'name'.

function<void()> testFn,
bool msg,
bool captureOut, bool captureLog,
bool captureErr,
TestCase::TestCaseOutCompareOptions opt)
{

!Line: 115 - style: inconclusive: Function 'TestCase' argument 2 names different: declaration 'test' definition 'testFn'. [funcArgNamesDifferent]

!Line: 133 - note: Function 'TestCase' argument 2 names different: declaration 'test' definition 'testFn'.
!Line: 115 - note: Function 'TestCase' argument 2 names different: declaration 'test' definition 'testFn'.

bool msg,
bool captureOut, bool captureLog,
bool captureErr,
TestCase::TestCaseOutCompareOptions opt)
{
this->notifyTestPassed = msg;

!Line: 116 - style: inconclusive: Function 'TestCase' argument 3 names different: declaration 'testPassedMessage' definition 'msg'. [funcArgNamesDifferent]

!Line: 134 - note: Function 'TestCase' argument 3 names different: declaration 'testPassedMessage' definition 'msg'.
!Line: 116 - note: Function 'TestCase' argument 3 names different: declaration 'testPassedMessage' definition 'msg'.

void TestCase::logTestFailure (string reason) {
unique_ptr<ostream> logStream = nullptr;
if (this->clogOriginal.get() != nullptr) {
logStream = unique_ptr<ostream>(
new ostream(this->clogOriginal.get().get())

!Line: 304 - style: inconclusive: Function 'logTestFailure' argument 1 names different: declaration 'failureMessage' definition 'reason'. [funcArgNamesDifferent]

!Line: 299 - note: Function 'logTestFailure' argument 1 names different: declaration 'failureMessage' definition 'reason'.
!Line: 304 - note: Function 'logTestFailure' argument 1 names different: declaration 'failureMessage' definition 'reason'.

void TestCase::setNotifyPassed (bool notify) {
this->notifyTestPassed = notify;
}
void TestCase::captureStdout () {
if (TestCase::stdoutCaptureCasesConstructed ==

!Line: 371 - style: inconclusive: Function 'setNotifyPassed' argument 1 names different: declaration 'shouldNotify' definition 'notify'. [funcArgNamesDifferent]

!Line: 180 - note: Function 'setNotifyPassed' argument 1 names different: declaration 'shouldNotify' definition 'notify'.
!Line: 371 - note: Function 'setNotifyPassed' argument 1 names different: declaration 'shouldNotify' definition 'notify'.

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

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

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

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

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

!Line: 489 - 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: 494 - 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: 494 - 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: 145 - 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: 234 - 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: 292 - 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(std::move(suiteName));
this->tests = vector<TestCase>();

!Line: 80 - 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(std::move(suiteName));
this->tests = vector<TestCase>();

!Line: 80 - 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(std::move(suiteName));
this->tests = vector<TestCase>();

!Line: 80 - 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(std::move(suiteName));
this->tests = vector<TestCase>();

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

inline addTests () { }
/**
* @brief Add one or more tests at once to the test suite.
* @param test The first test to add.
* @param tests The rest of the tests to add.

!Line: 117 - performance: inconclusive: Technically the member function 'TestCPP::TestSuite::addTests' can be static (but you may consider moving to unnamed namespace). [functionStatic]

unsigned getLastRunFailCount ();
/**
* @brief Run all tests in the test suite.
*/
void run ();

!Line: 153 - style: inconclusive: Technically the member function 'TestCPP::TestSuite::getLastRunFailCount' can be const. [functionConst]

!Line: 73 - note: Technically the member function 'TestCPP::TestSuite::getLastRunFailCount' can be const.
!Line: 153 - note: Technically the member function 'TestCPP::TestSuite::getLastRunFailCount' can be const.

const string& getName ();
/**
* @brief Output the test object name to the specified stream.
* @param s The stream to output to.
* @param tcName The test object name object.

!Line: 81 - style: inconclusive: Technically the member function 'TestCPP::TestObjName::getName' can be const. [functionConst]

!Line: 59 - note: Technically the member function 'TestCPP::TestObjName::getName' can be const.
!Line: 81 - note: Technically the member function 'TestCPP::TestObjName::getName' can be const.

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.

1 participant