Skip to content

Commit

Permalink
Don't query binary version if analyzer binary is not found
Browse files Browse the repository at this point in the history
Don't print missing analyzer warning unless the analyzer list
is explicitly provided
  • Loading branch information
dkrupp authored and bruntib committed Sep 13, 2024
1 parent bd301ee commit a613f75
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion analyzer/codechecker_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def perform_analysis(args, skip_handlers, rs_handler: ReviewStatusHandler,
end_time = time.time()
LOG.info("Analysis length: %s sec.", end_time - start_time)

analyzer_types.print_unsupported_analyzers(errored)
if args.analyzers:
analyzer_types.print_unsupported_analyzers(errored)

metadata_tool['timestamps'] = {'begin': start_time,
'end': end_time}
Expand Down
2 changes: 1 addition & 1 deletion analyzer/codechecker_analyzer/analyzers/analyzer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def is_ignore_conflict_supported():
def print_unsupported_analyzers(errored):
""" Print error messages which occured during analyzer detection. """
for analyzer_binary, reason in errored:
LOG.warning("Analyzer '%s' is enabled but CodeChecker is failed to "
LOG.warning("Analyzer '%s' is enabled but CodeChecker failed to "
"execute analysis with it: '%s'. Please check your "
"'PATH' environment variable and the "
"'config/package_layout.json' file!",
Expand Down
4 changes: 2 additions & 2 deletions analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ def analyzer_binary(cls):

@classmethod
def get_binary_version(cls, details=False) -> str:
if not cls.analyzer_binary():
return None
# No need to LOG here, we will emit a warning later anyway.
environ = analyzer_context.get_context().get_env_for_bin(
cls.analyzer_binary())
if not cls.analyzer_binary():
return None

version = [cls.analyzer_binary(), '--version']
try:
Expand Down
4 changes: 2 additions & 2 deletions analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def analyzer_binary(cls):
def get_binary_version(cls, details=False) -> str:
""" Get analyzer version information. """
# No need to LOG here, we will emit a warning later anyway.
environ = analyzer_context.get_context().get_env_for_bin(
cls.analyzer_binary())
if not cls.analyzer_binary():
return None
environ = analyzer_context.get_context().get_env_for_bin(
cls.analyzer_binary())
version = [cls.analyzer_binary(), '--version']
try:
output = subprocess.check_output(version,
Expand Down
4 changes: 2 additions & 2 deletions analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def get_binary_version(cls, details=False) -> str:
"""
Return the analyzer version.
"""
environ = analyzer_context.get_context().get_env_for_bin(
cls.analyzer_binary())
# No need to LOG here, we will emit a warning later anyway.
if not cls.analyzer_binary():
return None
environ = analyzer_context.get_context().get_env_for_bin(
cls.analyzer_binary())
if details:
version = [cls.analyzer_binary(), '--version']
else:
Expand Down
5 changes: 4 additions & 1 deletion analyzer/codechecker_analyzer/cmd/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,10 @@ def __print_checker_config(args: argparse.Namespace):
if rows:
print(twodim.to_str(args.output_format, header, rows))

analyzer_types.print_unsupported_analyzers(errored)
# Don't print this warning unless the analyzer list is
# given by the user.
if args.analyzers:
analyzer_types.print_unsupported_analyzers(errored)

if analyzer_failures:
LOG.error("Failed to get checker configuration options for '%s' "
Expand Down

0 comments on commit a613f75

Please sign in to comment.