Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions ament_cppcheck/ament_cppcheck/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ def find_cppcheck_executable():
def get_cppcheck_version(cppcheck_bin):
version_cmd = [cppcheck_bin, '--version']
output = subprocess.check_output(version_cmd)
# expecting something like b'Cppcheck 1.88\n'
# expecting something like b'Cppcheck 1.88\n' or b'Cppcheck 2.7 dev'
output = output.decode().strip()
tokens = output.split()
if len(tokens) != 2:
if len(tokens) not in (2, 3):
raise RuntimeError("unexpected cppcheck version string '{}'".format(output))

if tokens[0] != 'Cppcheck':
raise RuntimeError("unexpected cppcheck version name '{}'".format(output))

return tokens[1]


Expand Down Expand Up @@ -118,20 +122,20 @@ def main(argv=sys.argv[1:]):
# the number of cores cannot be determined, do not extend args
pass

# detect cppcheck 1.88 which caused issues
if 'AMENT_CPPCHECK_ALLOW_1_88' not in os.environ:
if cppcheck_version == '1.88':
# detect cppcheck 1.88 or 2.x which are much too slow
if 'AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS' not in os.environ:
if cppcheck_version == '1.88' or cppcheck_version.startswith('2.'):
print(
'cppcheck 1.88 has known performance issues and therefore will not be used, '
'set the AMENT_CPPCHECK_ALLOW_1_88 environment variable to override this.',
f'cppcheck {cppcheck_version} has known performance issues and therefore will not '
'be used, set the AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS environment variable to override this.',
file=sys.stderr,
)

if args.xunit_file:
report = {input_file: [] for input_file in files}
write_xunit_file(
args.xunit_file, report, time.time() - start_time,
skip='cppcheck 1.88 performance issues'
skip=f'cppcheck {cppcheck_version} performance issues'
)
return 0

Expand Down