Skip to content

Commit

Permalink
Disable cppcheck 2.x. (#345)
Browse files Browse the repository at this point in the history
* Disable cppcheck 2.x.

It has known performance issues (more than 10x slower than
cppcheck 1.9), so just get out early and don't run it.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette authored Jan 14, 2022
1 parent 0e59b81 commit e4e45fc
Showing 1 changed file with 12 additions and 8 deletions.
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

0 comments on commit e4e45fc

Please sign in to comment.