@@ -65,14 +65,13 @@ class WindowsError(Exception):
6565from scancode import notice
6666from scancode import print_about
6767from scancode import Scanner
68- from scancode import resource_cache
68+ from scancode import results_cache
6969from scancode .help import epilog_text
7070from scancode .help import examples_text
7171from scancode .interrupt import DEFAULT_TIMEOUT
7272from scancode .interrupt import fake_interruptible
7373from scancode .interrupt import interruptible
7474from scancode .pool import ScanCodeTimeoutError
75- from scancode_config import USE_CACHED_RESULTS
7675
7776# Tracing flags
7877TRACE = False
@@ -394,6 +393,13 @@ def default_processes():
394393 # not yet supported in Click 6.7 but added in PluggableCommandLineOption
395394 hidden = True ,
396395 help_group = cliutils .MISC_GROUP , sort_order = 1000 , cls = PluggableCommandLineOption )
396+
397+ @click .option ('--no-cached-results' ,
398+ is_flag = True ,
399+ default = False ,
400+ hidden = True ,
401+ help = 'ScanCode will not use cached results during scan time.' ,
402+ help_group = cliutils .CORE_GROUP , sort_order = 250 , cls = PluggableCommandLineOption )
397403def scancode (
398404 ctx ,
399405 input , # NOQA
@@ -412,6 +418,7 @@ def scancode(
412418 test_error_mode ,
413419 keep_temp_files ,
414420 check_version ,
421+ no_cached_results ,
415422 echo_func = echo_stderr ,
416423 * args ,
417424 ** kwargs ,
@@ -526,6 +533,7 @@ def scancode(
526533 return_results = False ,
527534 echo_func = echo_func ,
528535 outdated = outdated ,
536+ use_cached_results = not no_cached_results ,
529537 * args ,
530538 ** kwargs
531539 )
@@ -569,6 +577,7 @@ def run_scan(
569577 pretty_params = None ,
570578 plugin_options = plugin_options ,
571579 outdated = None ,
580+ use_cached_results = False ,
572581 * args ,
573582 ** kwargs
574583):
@@ -973,6 +982,7 @@ def echo_func(*_args, **_kwargs):
973982 verbose = verbose ,
974983 kwargs = requested_options ,
975984 echo_func = echo_func ,
985+ use_cached_results = use_cached_results ,
976986 )
977987 success = success and scan_success
978988
@@ -1165,6 +1175,7 @@ def run_scanners(
11651175 verbose = False ,
11661176 kwargs = None ,
11671177 echo_func = echo_stderr ,
1178+ use_cached_results = False ,
11681179):
11691180 """
11701181 Run the list of `stage` ScanPlugin `plugins` on `codebase`.
@@ -1206,7 +1217,8 @@ def run_scanners(
12061217 # TODO: add CLI option to bypass cache entirely?
12071218 scan_success = scan_codebase (
12081219 codebase , scanners , processes , timeout ,
1209- with_timing = timing , progress_manager = progress_manager )
1220+ with_timing = timing , progress_manager = progress_manager ,
1221+ use_cached_results = use_cached_results )
12101222
12111223 # TODO: add progress indicator
12121224 # run the process codebase of each scan plugin (most often a no-op)
@@ -1244,6 +1256,7 @@ def scan_codebase(
12441256 with_timing = False ,
12451257 progress_manager = None ,
12461258 echo_func = echo_stderr ,
1259+ use_cached_results = False ,
12471260):
12481261 """
12491262 Run the `scanners` Scanner objects on the `codebase` Codebase. Return True
@@ -1273,7 +1286,8 @@ def scan_codebase(
12731286 scanners = scanners ,
12741287 timeout = timeout ,
12751288 with_timing = with_timing ,
1276- with_threading = use_threading
1289+ with_threading = use_threading ,
1290+ use_cached_results = use_cached_results ,
12771291 )
12781292
12791293 if TRACE :
@@ -1406,6 +1420,7 @@ def scan_resource(
14061420 timeout = DEFAULT_TIMEOUT ,
14071421 with_timing = False ,
14081422 with_threading = True ,
1423+ use_cached_results = False ,
14091424):
14101425 """
14111426 Given a ``location_path`` tuple pf (location, path), return a tuple of:
@@ -1443,16 +1458,17 @@ def scan_resource(
14431458 # and start returning values. The kill timeout is otherwise there
14441459 # as a gatekeeper for runaway processes.
14451460
1446- # compute resource_cache_index
1447- resource_cache_index = resource_cache .compute_resource_cache_index (location = location , path = path )
1461+ results_cache_index = ''
1462+ if use_cached_results :
1463+ # compute results_cache_index
1464+ results_cache_index = results_cache .compute_results_cache_index (location = location , path = path )
14481465
1449- if USE_CACHED_RESULTS :
14501466 # update `results` with cached data or add scanner to scanners_to_run if no
14511467 # cache data is available
14521468 for scanner in scanners :
14531469 # get resource_cache_data
1454- resource_cache_data = resource_cache . get_resource_cache_data (
1455- resource_cache_index = resource_cache_index ,
1470+ resource_cache_data = results_cache . get_results_cache_data (
1471+ results_cache_index = results_cache_index ,
14561472 plugin_name = scanner .name
14571473 )
14581474 if resource_cache_data :
@@ -1480,9 +1496,9 @@ def scan_resource(
14801496 # the return value of a scanner fun MUST be a mapping
14811497 if values_mapping :
14821498 results .update (values_mapping )
1483- if USE_CACHED_RESULTS :
1484- resource_cache . update_resource_cache_data (
1485- resource_cache_index = resource_cache_index ,
1499+ if use_cached_results :
1500+ results_cache . update_results_cache_data (
1501+ results_cache_index = results_cache_index ,
14861502 plugin_name = scanner .name ,
14871503 results = values_mapping ,
14881504 )
0 commit comments