Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable cppcheck 2.x. #345

Merged
merged 3 commits into from
Jan 14, 2022
Merged
Changes from 2 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_1_88 environment variable to override this.',
clalancette marked this conversation as resolved.
Show resolved Hide resolved
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