cppcheck doesn't always report a filename for an error.
Added some error checking so this tool doesn't crash.
This commit is contained in:
parent
f1ad308f5f
commit
c83f446412
|
@ -161,6 +161,8 @@ class CppCheckHandler(XmlContentHandler):
|
||||||
if name != "error":
|
if name != "error":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if attributes["file"] == "":
|
||||||
|
sys.stderr.write("ERROR: cppcheck error reported without a file name.\n")
|
||||||
self.errors.append(
|
self.errors.append(
|
||||||
{
|
{
|
||||||
"file" : attributes["file"],
|
"file" : attributes["file"],
|
||||||
|
@ -233,6 +235,9 @@ if __name__ == '__main__':
|
||||||
lines.append(error["line"])
|
lines.append(error["line"])
|
||||||
|
|
||||||
source_file = os.path.join(source_dir, filename)
|
source_file = os.path.join(source_dir, filename)
|
||||||
|
if not os.path.isfile(source_file):
|
||||||
|
sys.stderr.write("ERROR: Source file '%s' not found.\n" % source_file)
|
||||||
|
continue
|
||||||
stream = file(source_file)
|
stream = file(source_file)
|
||||||
content = stream.read()
|
content = stream.read()
|
||||||
stream.close()
|
stream.close()
|
||||||
|
|
Loading…
Reference in New Issue