Skip to content

Commit

Permalink
Fix issue with Cppcheck command's standard error stream
Browse files Browse the repository at this point in the history
- Newer versions of Cppcheck might output all the errors on stderr
  (tested with Cppcheck 2.4.1)
  • Loading branch information
Takishima committed Jun 18, 2021
1 parent bae9615 commit 7135ffe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hooks/cppcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ def run(self):
self.run_command(filename)
# Useless error see https://stackoverflow.com/questions/6986033
useless_error_part = "Cppcheck cannot find all the include files"
if useless_error_part in self.stderr:
self.stderr = ""
err_lines = self.stderr.splitlines(keepends=True)
for idx, line in enumerate(err_lines):
if useless_error_part in line:
err_lines[idx] = ''
self.stderr = ''.join(err_lines)
if self.returncode != 0:
sys.stderr.write(self.stdout + self.stderr)
sys.exit(self.returncode)
Expand Down

0 comments on commit 7135ffe

Please sign in to comment.