|
22 | 22 | #include "fixture.h" |
23 | 23 | #include "helpers.h" |
24 | 24 |
|
| 25 | +#include <cmath> |
25 | 26 | #include <string> |
26 | 27 | #include <vector> |
27 | 28 |
|
@@ -61,21 +62,21 @@ class TestSarifReport : public TestFixture |
61 | 62 |
|
62 | 63 | // Helper to create an ErrorMessage |
63 | 64 | static ErrorMessage createErrorMessage(const std::string& id, |
64 | | - Severity severity, |
65 | | - const std::string& msg, |
66 | | - const std::string& file = "test.cpp", |
67 | | - int line = 10, |
68 | | - int column = 5, |
69 | | - int cweId = 0, |
70 | | - Certainty certainty = Certainty::normal) |
| 65 | + Severity severity, |
| 66 | + const std::string& msg, |
| 67 | + const std::string& file = "test.cpp", |
| 68 | + int line = 10, |
| 69 | + int column = 5, |
| 70 | + int cweId = 0, |
| 71 | + Certainty certainty = Certainty::normal) |
71 | 72 | { |
72 | 73 | ErrorMessage::FileLocation loc(file, line, column); |
73 | | - ErrorMessage errmsg({loc}, file, severity, msg, id, certainty); |
| 74 | + ErrorMessage errorMessage({loc}, file, severity, msg, id, certainty); |
74 | 75 | if (cweId > 0) |
75 | 76 | { |
76 | | - errmsg.cwe = CWE(cweId); |
| 77 | + errorMessage.cwe = CWE(cweId); |
77 | 78 | } |
78 | | - return errmsg; |
| 79 | + return errorMessage; |
79 | 80 | } |
80 | 81 |
|
81 | 82 | // Helper to parse JSON and validate structure |
@@ -173,8 +174,9 @@ class TestSarifReport : public TestFixture |
173 | 174 | SarifReport report; |
174 | 175 |
|
175 | 176 | // Create error without location (empty callStack) |
176 | | - ErrorMessage errmsg({}, "test.cpp", Severity::error, "Error without location", "testError", Certainty::normal); |
177 | | - report.addFinding(errmsg); |
| 177 | + ErrorMessage errorMessage( |
| 178 | + {}, "test.cpp", Severity::error, "Error without location", "testError", Certainty::normal); |
| 179 | + report.addFinding(errorMessage); |
178 | 180 |
|
179 | 181 | std::string sarif = report.serialize("Cppcheck"); |
180 | 182 | picojson::value json; |
@@ -202,13 +204,13 @@ class TestSarifReport : public TestFixture |
202 | 204 | ErrorMessage::FileLocation loc2("test2.cpp", 20, 10); |
203 | 205 | ErrorMessage::FileLocation loc3("test3.cpp", 30, 15); |
204 | 206 |
|
205 | | - ErrorMessage errmsg({loc1, loc2, loc3}, |
206 | | - "test1.cpp", |
207 | | - Severity::error, |
208 | | - "Error with multiple locations", |
209 | | - "multiLocError", |
210 | | - Certainty::normal); |
211 | | - report.addFinding(errmsg); |
| 207 | + ErrorMessage errorMessage({loc1, loc2, loc3}, |
| 208 | + "test1.cpp", |
| 209 | + Severity::error, |
| 210 | + "Error with multiple locations", |
| 211 | + "multiLocError", |
| 212 | + Certainty::normal); |
| 213 | + report.addFinding(errorMessage); |
212 | 214 |
|
213 | 215 | std::string sarif = report.serialize("Cppcheck"); |
214 | 216 | picojson::value json; |
@@ -390,7 +392,7 @@ class TestSarifReport : public TestFixture |
390 | 392 | report.addFinding( |
391 | 393 | createErrorMessage("test1", Severity::error, "Conclusive", "test.cpp", 10, 5, 0, Certainty::normal)); |
392 | 394 | report.addFinding(createErrorMessage( |
393 | | - "test2", Severity::error, "Inconclusive", "test.cpp", 20, 5, 0, Certainty::inconclusive)); |
| 395 | + "test2", Severity::error, "Inconclusive", "test.cpp", 20, 5, 0, Certainty::inconclusive)); |
394 | 396 |
|
395 | 397 | std::string sarif = report.serialize("Cppcheck"); |
396 | 398 | picojson::value json; |
@@ -475,11 +477,11 @@ class TestSarifReport : public TestFixture |
475 | 477 | ErrorMessage::FileLocation loc1("test.cpp", 0, 0); |
476 | 478 | ErrorMessage::FileLocation loc2("test.cpp", 1, 1); |
477 | 479 |
|
478 | | - ErrorMessage errmsg1({loc1}, "test.cpp", Severity::error, "Error at 0,0", "error1", Certainty::normal); |
479 | | - ErrorMessage errmsg2({loc2}, "test.cpp", Severity::error, "Error at 1,1", "error2", Certainty::normal); |
| 480 | + ErrorMessage errorMessage1({loc1}, "test.cpp", Severity::error, "Error at 0,0", "error1", Certainty::normal); |
| 481 | + ErrorMessage errorMessage2({loc2}, "test.cpp", Severity::error, "Error at 1,1", "error2", Certainty::normal); |
480 | 482 |
|
481 | | - report.addFinding(errmsg1); |
482 | | - report.addFinding(errmsg2); |
| 483 | + report.addFinding(errorMessage1); |
| 484 | + report.addFinding(errorMessage2); |
483 | 485 |
|
484 | 486 | std::string sarif = report.serialize("Cppcheck"); |
485 | 487 | picojson::value json; |
@@ -713,14 +715,14 @@ class TestSarifReport : public TestFixture |
713 | 715 |
|
714 | 716 | // Test with 0 values |
715 | 717 | ErrorMessage::FileLocation loc0("test.cpp", 0, 0); |
716 | | - ErrorMessage errmsg0({loc0}, "test.cpp", Severity::error, "Error at 0", "error0", Certainty::normal); |
717 | | - report.addFinding(errmsg0); |
| 718 | + ErrorMessage errorMessage0({loc0}, "test.cpp", Severity::error, "Error at 0", "error0", Certainty::normal); |
| 719 | + report.addFinding(errorMessage0); |
718 | 720 |
|
719 | 721 | // Test with positive values |
720 | 722 | ErrorMessage::FileLocation locPos("test.cpp", 10, 5); |
721 | | - ErrorMessage errmsgPos( |
| 723 | + ErrorMessage errorMessagePos( |
722 | 724 | {locPos}, "test.cpp", Severity::error, "Error at positive", "errorPos", Certainty::normal); |
723 | | - report.addFinding(errmsgPos); |
| 725 | + report.addFinding(errorMessagePos); |
724 | 726 |
|
725 | 727 | std::string sarif = report.serialize("Cppcheck"); |
726 | 728 | picojson::value json; |
|
0 commit comments