Skip to content

Commit 706c0f7

Browse files
committedDec 5, 2024
Fix failing --no-check-version cli option
Currently, if the --no-check-version option is used, the scan fails because an unbound variable is passed to the run_scan function. Fix this by assigning None in that case. Add a test that passes with this change and fails without it. Signed-off-by: alexzurbonsen <alexander.zur.bonsen@tngtech.com>
1 parent 65e1c2d commit 706c0f7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎src/scancode/cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ def scancode(
480480
if check_version:
481481
from scancode.outdated import check_scancode_version
482482
outdated = check_scancode_version()
483+
else:
484+
outdated = None
483485

484486
# run proper
485487
success, _results = run_scan(

‎tests/scancode/test_cli.py

+6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ def test_run_scan_includes_outdated_in_extra():
121121
assert results['headers'][0]['extra_data']['OUTDATED'] == 'out of date'
122122

123123

124+
def test_no_version_check_run_is_successful():
125+
test_file = test_env.get_test_loc('single/iproute.c')
126+
result_file = test_env.get_temp_file('json')
127+
run_scan_click(['--no-check-version', test_file, '--json', result_file], expected_rc=0)
128+
129+
124130
def test_usage_and_help_return_a_correct_script_name_on_all_platforms():
125131
result = run_scan_click(['--help'])
126132
assert 'Usage: scancode [OPTIONS]' in result.output

0 commit comments

Comments
 (0)