diff --git a/.gitignore b/.gitignore index 202de28..95ab5d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /cppcheck_result.json -/cppcheck_error.xml \ No newline at end of file +/cppcheck_error.xml +analysis_config.json diff --git a/analysis_config.json b/analysis_config.json deleted file mode 100644 index bc6686c..0000000 --- a/analysis_config.json +++ /dev/null @@ -1 +0,0 @@ -{ "files": [ "test.c" ] } diff --git a/src/cppcheck.rs b/src/cppcheck.rs index 4571baf..e29f30c 100644 --- a/src/cppcheck.rs +++ b/src/cppcheck.rs @@ -25,7 +25,8 @@ pub struct Error { #[serde(rename = "@cwe")] pub cwe: Option, pub location: Option>, - pub symbol: Option, + #[serde(default)] + pub symbol: Vec, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/main.rs b/src/main.rs index fb5d177..c5ca2e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,11 @@ fn _main() -> Result<(), Box> { format!( "{} {}", error.id, - error.symbol.unwrap_or_else(|| "".to_string()) + error + .symbol + .get(0) + .map(String::as_str) + .unwrap_or_else(|| "") ) } else { error.msg