Skip to content

Commit 5474521

Browse files
Fix unreachable JSON validation code in validate_input_path
The .json extension check and JSON well-formedness check after the 'raise click.BadParameter' were unreachable dead code. Move these validations into a separate conditional block that runs when from_json is True and the input is a valid file. Signed-off-by: codewithfourtix <codewithfourtix@gmail.com>
1 parent d320c97 commit 5474521

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/scancode/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ def validate_input_path(ctx, param, value):
192192
if from_json and not is_file(location=inp, follow_symlinks=True):
193193
# extra JSON validation
194194
raise click.BadParameter(f"JSON input: {inp!r} is not a file")
195+
196+
if from_json and is_file(location=inp, follow_symlinks=True):
195197
if not inp.lower().endswith(".json"):
196198
raise click.BadParameter(f"JSON input: {inp!r} is not a JSON file with a .json extension")
197199
with open(inp) as js:

0 commit comments

Comments
 (0)