Skip to content

Commit 8289f8f

Browse files
fix: improve parsing output of cppcheck (#4)
* fix: improve parsing output of cppcheck cppcheck can produce malformed output which needs to be explicitly handled * fix: set default to C++20 * revert: default to `c11`
1 parent 7135ff3 commit 8289f8f

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/target
22
/cppcheck_result.json
3-
/cppcheck_error.xml
3+
/cppcheck_error.xml
4+
analysis_config.json

analysis_config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/cppcheck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub struct Error {
2525
#[serde(rename = "@cwe")]
2626
pub cwe: Option<String>,
2727
pub location: Option<Vec<Location>>,
28-
pub symbol: Option<String>,
28+
#[serde(default)]
29+
pub symbol: Vec<String>,
2930
}
3031

3132
#[derive(Serialize, Deserialize, Debug)]

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ fn _main() -> Result<(), Box<dyn Error>> {
109109
format!(
110110
"{} {}",
111111
error.id,
112-
error.symbol.unwrap_or_else(|| "".to_string())
112+
error
113+
.symbol
114+
.get(0)
115+
.map(String::as_str)
116+
.unwrap_or_else(|| "")
113117
)
114118
} else {
115119
error.msg

0 commit comments

Comments
 (0)