MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / run_scanners

Function run_scanners

src/scancode/cli.py:1172–1251  ·  view source on GitHub ↗

Run the list of `stage` ScanPlugin `plugins` on `codebase`. Update the codebase with computed counts and scan results. Return True on success and False otherwise. Kwargs are passed down when calling the process_codebase method of each plugin. Use multiple `processes` and l

(
    stage,
    plugins,
    codebase,
    processes,
    timeout,
    timing,
    quiet=False,
    verbose=False,
    kwargs=None,
    echo_func=echo_stderr,
)

Source from the content-addressed store, hash-verified

1170
1171
1172def run_scanners(
1173 stage,
1174 plugins,
1175 codebase,
1176 processes,
1177 timeout,
1178 timing,
1179 quiet=False,
1180 verbose=False,
1181 kwargs=None,
1182 echo_func=echo_stderr,
1183):
1184 """
1185 Run the list of `stage` ScanPlugin `plugins` on `codebase`.
1186 Update the codebase with computed counts and scan results.
1187 Return True on success and False otherwise.
1188
1189 Kwargs are passed down when calling the process_codebase method of each
1190 plugin.
1191
1192 Use multiple `processes` and limit the runtime of a single scanner
1193 function to `timeout` seconds.
1194 Compute detailed timings if `timing` is True.
1195 Display progress and errors based on the `quiet` and `verbose` flags.
1196 """
1197
1198 kwargs = kwargs or {}
1199
1200 scan_start = time()
1201
1202 scanners = []
1203 for plugin in plugins:
1204 func = plugin.get_scanner(**kwargs)
1205 scanners.append(Scanner(name=plugin.name, function=func))
1206
1207 if TRACE_DEEP: logger_debug('run_scanners: scanners:', scanners)
1208 if not scanners:
1209 return True
1210
1211 scan_names = ', '.join(s.name for s in scanners)
1212
1213 progress_manager = None
1214 if not quiet:
1215 echo_func(f'Scan files for: {scan_names} with {processes} process(es)...')
1216 item_show_func = partial(path_progress_message, verbose=verbose)
1217 progress_manager = partial(progressmanager,
1218 item_show_func=item_show_func,
1219 verbose=verbose, file=sys.stderr)
1220
1221 # TODO: add CLI option to bypass cache entirely?
1222 scan_success = scan_codebase(
1223 codebase, scanners, processes, timeout,
1224 with_timing=timing, progress_manager=progress_manager)
1225
1226 # TODO: add progress indicator
1227 # run the process codebase of each scan plugin (most often a no-op)
1228 scan_process_codebase_success = run_codebase_plugins(
1229 stage, plugins, codebase,

Callers 1

run_scanFunction · 0.85

Calls 9

echo_funcFunction · 0.85
partialFunction · 0.85
scan_codebaseFunction · 0.85
run_codebase_pluginsFunction · 0.85
compute_countsMethod · 0.80
logger_debugFunction · 0.70
get_scannerMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected