scancode.io icon indicating copy to clipboard operation
scancode.io copied to clipboard

Fix flag_and_ignore_files_over_max_size inconsistent return value and docstring

Open prajakta128 opened this issue 5 months ago • 1 comments

What

Fix flag_and_ignore_files_over_max_size in scanpipe/pipes/flag.py which had a misleading docstring and an implicit return value.

Why

The docstring claimed the function would: > "return all other files within the file size limit"

But .update() returns an integer (count of updated rows), not a queryset. This is inconsistent and confusing for anyone reading the code.

Evidence that the return value was misleading — the caller in scanpipe/pipes/scancode.py ignores the return value and manually re-filters: resource_qs.filter(~Q(status=flag.IGNORED_BY_MAX_FILE_SIZE))

Fix

  • Explicitly assign .update() result to flagged_count variable
  • Return flagged_count clearly
  • Update docstring to accurately say it returns the count of flagged files
  • Add regression tests to verify return type and correct flagging behavior

Files changed

  • scanpipe/pipes/flag.py — fix return value + docstring
  • scanpipe/tests/pipes/test_flag.py — add two regression tests

prajakta128 avatar Jun 26 '26 03:06 prajakta128

Hi maintainers! This PR fixes an inconsistent return value and misleading docstring in flag_and_ignore_files_over_max_size. Would love to get your feedback when you have a chance. Happy to make any changes needed. Thank you!

prajakta128 avatar Jul 04 '26 15:07 prajakta128