Skip to content

Commit 99fcaf4

Browse files
authored
Merge pull request #4330 from cservakt/missing-analyzer-error
[fix] Missing analyzer error
2 parents 6123768 + 39868a8 commit 99fcaf4

File tree

7 files changed

+30
-20
lines changed

7 files changed

+30
-20
lines changed

analyzer/codechecker_analyzer/analyzer.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ def perform_analysis(args, skip_handlers, rs_handler: ReviewStatusHandler,
142142
ctu_reanalyze_on_failure = 'ctu_reanalyze_on_failure' in args and \
143143
args.ctu_reanalyze_on_failure
144144

145-
analyzers = args.analyzers if 'analyzers' in args \
146-
else analyzer_types.supported_analyzers
147-
analyzers, errored = analyzer_types.check_supported_analyzers(analyzers)
148-
analyzer_types.check_available_analyzers(analyzers, errored)
145+
analyzers, errored = \
146+
analyzer_types.check_available_analyzers(args.analyzers)
149147

150148
ctu_collect = False
151149
ctu_analyze = False

analyzer/codechecker_analyzer/analyzer_context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def __populate_analyzers(self):
233233
self.__analyzers[name] = compiler_binary
234234

235235
def get_analyzer_env(self, analyzer_name):
236-
return self.__analyzer_envs[analyzer_name]
236+
return self.__analyzer_envs.get(analyzer_name)
237237

238238
def __populate_replacer(self):
239239
""" Set clang-apply-replacements tool. """

analyzer/codechecker_analyzer/analyzers/analyzer_types.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,28 @@ def print_unsupported_analyzers(errored):
122122
analyzer_binary, reason)
123123

124124

125-
def check_available_analyzers(analyzers, errored):
126-
""" Handle use case when no analyzer can be found on the user machine. """
127-
if analyzers:
128-
return
129-
130-
print_unsupported_analyzers(errored)
131-
LOG.error("Failed to run command because no analyzers can be found on "
132-
"your machine!")
133-
sys.exit(1)
125+
def check_available_analyzers(args_analyzers=None):
126+
"""
127+
Handle use case when no analyzer can be found or a supported, explicitly
128+
given analyzer cannot be found on the user machine.
129+
"""
130+
131+
if args_analyzers:
132+
analyzers, errored = check_supported_analyzers(args_analyzers)
133+
if errored:
134+
print_unsupported_analyzers(errored)
135+
LOG.error("Failed to run command because the given analyzer(s) "
136+
"cannot be found on your machine!")
137+
sys.exit(1)
138+
139+
else:
140+
analyzers, errored = check_supported_analyzers(supported_analyzers)
141+
if not analyzers:
142+
print_unsupported_analyzers(errored)
143+
LOG.error("Failed to run command because no analyzers can be "
144+
"found on your machine!")
145+
sys.exit(1)
146+
return analyzers, errored
134147

135148

136149
def check_supported_analyzers(analyzers):

analyzer/codechecker_analyzer/cmd/analyze.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def add_arguments_to_parser(parser):
372372
metavar='ANALYZER',
373373
required=False,
374374
choices=analyzer_types.supported_analyzers,
375-
default=argparse.SUPPRESS,
375+
default=None,
376376
help="Run analysis only with the analyzers "
377377
"specified. Currently supported analyzers "
378378
"are: " +

analyzer/codechecker_analyzer/cmd/analyzers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def uglify(text):
189189
check_env = context.get_analyzer_env(analyzer_name)
190190
version = analyzer_class.get_binary_version(check_env)
191191
if not version:
192-
version = 'ERROR'
192+
version = 'NOT FOUND'
193193

194194
binary = context.analyzer_binaries.get(analyzer_name)
195195
rows.append([analyzer_name, binary, version])

analyzer/codechecker_analyzer/cmd/check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def add_arguments_to_parser(parser):
305305
metavar='ANALYZER',
306306
required=False,
307307
choices=analyzer_types.supported_analyzers,
308-
default=argparse.SUPPRESS,
308+
default=None,
309309
help="Run analysis only with the analyzers "
310310
"specified. Currently supported analyzers "
311311
"are: " +

analyzer/codechecker_analyzer/cmd/checkers.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,8 @@ def __print_checker_config(args: argparse.Namespace):
522522
if args.output_format == 'custom':
523523
args.output_format = 'rows'
524524

525-
working_analyzers, errored = analyzer_types.check_supported_analyzers(
526-
args.analyzers)
527-
analyzer_types.check_available_analyzers(working_analyzers, errored)
525+
working_analyzers, errored = \
526+
analyzer_types.check_available_analyzers(args.analyzers)
528527

529528
if 'details' in args:
530529
header = ['Option', 'Description']

0 commit comments

Comments
 (0)