diff --git a/htmlreport/cppcheck-htmlreport b/htmlreport/cppcheck-htmlreport index 763cfbc0b..eacd38422 100755 --- a/htmlreport/cppcheck-htmlreport +++ b/htmlreport/cppcheck-htmlreport @@ -187,7 +187,7 @@ class CppCheckHandler(XmlContentHandler): self.errors.append({ "file" : attributes.get("file", ""), - "line" : int(attributes.get("line"), 0), + "line" : int(attributes.get("line", 0)), "id" : attributes["id"], "severity" : attributes["severity"], "msg" : attributes["msg"] diff --git a/htmlreport/example.cc b/htmlreport/example.cc new file mode 100644 index 000000000..9c0100487 --- /dev/null +++ b/htmlreport/example.cc @@ -0,0 +1,7 @@ +#include "missing.h" + +int main() +{ + int x; + x++; +} diff --git a/htmlreport/example.xml b/htmlreport/example.xml new file mode 100644 index 000000000..4807c8be4 --- /dev/null +++ b/htmlreport/example.xml @@ -0,0 +1,8 @@ + + +Checking example.cc... + + +Checking usage of global functions.. + + diff --git a/htmlreport/test_htmlreport.py b/htmlreport/test_htmlreport.py index 17b344656..6b71b9a38 100755 --- a/htmlreport/test_htmlreport.py +++ b/htmlreport/test_htmlreport.py @@ -63,9 +63,21 @@ class TestHTMLReport(unittest.TestCase): self.assertFalse( os.path.exists(os.path.join(output_directory, '0.html'))) + def testMissingInclude(self): + with runCheck( + xml_filename=os.path.join(ROOT_DIR, 'htmlreport', 'example.xml'), + ) as (report, output_directory): + self.assertIn('