@@ -267,7 +267,7 @@ int main() {
267267 // On Windows: Uses _popen/_pclose (mapped via #define)
268268 // On Unix/Linux/Mac: Uses popen/pclose
269269 // This avoids the need for complex process spawning APIs while maintaining compatibility
270- std::string runCppcheckSarif (const std::string& code)
270+ static std::string runCppcheckSarif (const std::string& code)
271271 {
272272 // Create temporary file
273273 const std::string filename = " sarif_test_temp.cpp" ;
@@ -352,7 +352,7 @@ int main() {
352352 }
353353
354354 // Helper to parse and validate SARIF JSON
355- bool validateSarifJson (const std::string& sarifOutput, std::string& errorMsg)
355+ static bool validateSarifJson (const std::string& sarifOutput, std::string& errorMsg)
356356 {
357357 if (sarifOutput.empty ())
358358 {
@@ -466,7 +466,7 @@ int main() {
466466 const picojson::object& sarifRun = runs[0 ].get <picojson::object>();
467467 const picojson::array& results = sarifRun.at (" results" ).get <picojson::array>();
468468
469- ASSERT (results.size () > 0 );
469+ ASSERT (! results.empty () );
470470
471471 // Check that we have different severity levels and meaningful messages
472472 bool hasError = false ;
@@ -486,7 +486,7 @@ int main() {
486486 const std::string messageText = message.at (" text" ).get <std::string>();
487487
488488 // Messages should be non-empty and meaningful
489- ASSERT (messageText.length () > 0 );
489+ ASSERT (! messageText.empty () );
490490 if (messageText.length () > 5 ) // Reasonable minimum for a meaningful message
491491 {
492492 hasNonEmptyMessage = true ;
@@ -514,7 +514,7 @@ int main() {
514514 const picojson::object& driver = tool.at (" driver" ).get <picojson::object>();
515515 const picojson::array& rules = driver.at (" rules" ).get <picojson::array>();
516516
517- ASSERT (rules.size () > 0 );
517+ ASSERT (! rules.empty () );
518518
519519 // Check rule structure
520520 for (const auto & rule : rules)
@@ -577,7 +577,7 @@ int main() {
577577 bool hasCweTag = false ;
578578 for (const auto & tag : tags)
579579 {
580- const std::string tagStr = tag.get <std::string>();
580+ const std::string& tagStr = tag.get <std::string>();
581581 if (tagStr == " security" )
582582 {
583583 hasSecurityTag = true ;
@@ -608,7 +608,7 @@ int main() {
608608 const picojson::object& sarifRun = runs[0 ].get <picojson::object>();
609609 const picojson::array& results = sarifRun.at (" results" ).get <picojson::array>();
610610
611- ASSERT (results.size () > 0 );
611+ ASSERT (! results.empty () );
612612
613613 // Check location information
614614 for (const auto & result : results)
@@ -617,7 +617,7 @@ int main() {
617617
618618 ASSERT (res.find (" locations" ) != res.end ());
619619 const picojson::array& locations = res.at (" locations" ).get <picojson::array>();
620- ASSERT (locations.size () > 0 );
620+ ASSERT (! locations.empty () );
621621
622622 for (const auto & location : locations)
623623 {
@@ -702,7 +702,7 @@ int main() {
702702 const picojson::object& sarifRun = runs[0 ].get <picojson::object>();
703703 const picojson::array& results = sarifRun.at (" results" ).get <picojson::array>();
704704
705- ASSERT (results.size () > 0 );
705+ ASSERT (! results.empty () );
706706
707707 // Validate that results contain instance-specific information
708708 bool foundArrayBoundsWithSpecifics = false ;
@@ -806,8 +806,7 @@ int main() {
806806 }
807807
808808 // Verify that all messages are non-empty and meaningful
809- ASSERT (messageText.length () > 0 );
810- ASSERT (messageText != " " );
809+ ASSERT (!messageText.empty ());
811810
812811 // Messages should not contain generic placeholders
813812 ASSERT_EQUALS (std::string::npos, messageText.find (" {{" ));
@@ -857,7 +856,7 @@ int main() {
857856
858857 for (const auto & tag : tags)
859858 {
860- const std::string tagStr = tag.get <std::string>();
859+ const std::string& tagStr = tag.get <std::string>();
861860 if (tagStr == " security" )
862861 {
863862 hasSecurityTag = true ;
@@ -871,7 +870,7 @@ int main() {
871870 // Validate CWE tag format: external/cwe/cwe-<number>
872871 ASSERT_EQUALS (0 , tagStr.find (" external/cwe/cwe-" ));
873872 std::string cweNumber = tagStr.substr (17 ); // After "external/cwe/cwe-"
874- ASSERT (cweNumber.length () > 0 );
873+ ASSERT (! cweNumber.empty () );
875874
876875 // Verify it's a valid number
877876 for (char c : cweNumber)
@@ -977,7 +976,7 @@ int main() {
977976 const picojson::object& sarifRun = runs[0 ].get <picojson::object>();
978977 const picojson::array& results = sarifRun.at (" results" ).get <picojson::array>();
979978
980- ASSERT (results.size () > 0 );
979+ ASSERT (! results.empty () );
981980
982981 // Track different severity levels
983982 bool hasError = false ;
@@ -1095,7 +1094,7 @@ int main() {
10951094 const picojson::array& tags = props.at (" tags" ).get <picojson::array>();
10961095 for (const auto & tag : tags)
10971096 {
1098- const std::string tagStr = tag.get <std::string>();
1097+ const std::string& tagStr = tag.get <std::string>();
10991098 ASSERT (tagStr != " security" );
11001099 }
11011100 }
0 commit comments