From 60bf00bb31b05cda403f4c17a53ac0dc781b4689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Umann?= Date: Thu, 19 Oct 2023 17:00:56 +0200 Subject: [PATCH] Much more errors to be fixed --- analyzer/codechecker_analyzer/analyzer.py | 3 +- .../analyzers/clangtidy/analyzer.py | 2 +- .../analyzers/cppcheck/analyzer.py | 2 +- .../codechecker_analyzer/cmd/analyzers.py | 31 ++++++++++++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/analyzer/codechecker_analyzer/analyzer.py b/analyzer/codechecker_analyzer/analyzer.py index ecda285de0..74de35dd2d 100644 --- a/analyzer/codechecker_analyzer/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzer.py @@ -226,7 +226,8 @@ def perform_analysis(args, skip_handlers, actions, metadata_tool, # TODO: cppcheck may require a different environment than clang. version = analyzer_types.supported_analyzers[analyzer] \ - .get_binary_version(context.analyzer_env) + .get_binary_version(context.analyzer_binaries[analyzer], + context.analyzer_env) metadata_info['analyzer_statistics']['version'] = version metadata_tool['analyzers'][analyzer] = metadata_info diff --git a/analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py b/analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py index c17887e425..6ea3f7c8fb 100644 --- a/analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py @@ -242,7 +242,7 @@ def get_binary_version(self, configured_binary, environ, details=False) \ encoding="utf-8", errors="ignore") if details: - return output + return output.strip() return parse_version(output) except (subprocess.CalledProcessError, OSError) as oerr: LOG.warning("Failed to get analyzer version: %s", diff --git a/analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py b/analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py index d53da9514e..910c5662d8 100644 --- a/analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py +++ b/analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py @@ -94,7 +94,7 @@ def get_binary_version(self, configured_binary, environ, details=False) \ encoding="utf-8", errors="ignore") if details: - return output + return output.strip() return parse_version(output) except (subprocess.CalledProcessError, OSError) as oerr: LOG.warning("Failed to get analyzer version: %s", diff --git a/analyzer/codechecker_analyzer/cmd/analyzers.py b/analyzer/codechecker_analyzer/cmd/analyzers.py index 5d1f9cf7a0..2ea090a2c1 100644 --- a/analyzer/codechecker_analyzer/cmd/analyzers.py +++ b/analyzer/codechecker_analyzer/cmd/analyzers.py @@ -113,7 +113,7 @@ def main(args): logger.setup_logger(args.verbose if 'verbose' in args else None, stream) context = analyzer_context.get_context() - working_analyzers, errored = \ + _, errored = \ analyzer_types.check_supported_analyzers( analyzer_types.supported_analyzers) @@ -163,16 +163,21 @@ def uglify(text): configs = analyzer_class.get_analyzer_config() if not configs: - LOG.warning(f"No analyzer configurations found for '{analyzer}'. " - "If you suspsect this shouldn't be the case, try to " - "update your analyzer or check whether CodeChecker " - "found the intended binary.") + LOG.warning("No analyzer configurations found for " + f"'{analyzer_name}'. If you suspsect this shouldn't " + "be the case, try to update your analyzer or check " + "whether CodeChecker found the intended binary.") rows = [(':'.join((analyzer_name, c[0])), c[1]) if 'details' in args else (':'.join((analyzer_name, c[0])),) for c in configs] print(twodim.to_str(args.output_format, header, rows)) + for err_analyzer_name, err_reason in errored: + if analyzer_name == err_analyzer_name: + LOG.warning( + f"Can't analyze with '{analyzer_name}': {err_reason}") + return header = ['Name', 'Version', 'Path'] @@ -195,9 +200,19 @@ def uglify(text): rows.append([analyzer_name, version, binary]) - if rows: + assert rows + if 'details' not in args: print(twodim.to_str(args.output_format, header, rows)) + else: + for row in rows: + print(''.join(f""" +Analyzer name: {row[0]} +Path to binary: {row[2]} +Version info: + +{row[1]} +--------- +""")) for analyzer_name, err_reason in errored: - if 'details' not in args: - print(f"Can't analyze with '{analyzer_name}': {err_reason}") + LOG.warning(f"Can't analyze with '{analyzer_name}': {err_reason}")