Skip to content

Fix flag_and_ignore_files_over_max_size inconsistent return value and docstring#2184

Open
prajakta128 wants to merge 1 commit into
aboutcode-org:mainfrom
prajakta128:fix/flag-and-ignore-files-over-max-size-return-value
Open

Fix flag_and_ignore_files_over_max_size inconsistent return value and docstring#2184
prajakta128 wants to merge 1 commit into
aboutcode-org:mainfrom
prajakta128:fix/flag-and-ignore-files-over-max-size-return-value

Conversation

@prajakta128

Copy link
Copy Markdown

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

… docstring

The function docstring claimed to return the remaining files queryset
within the file size limit, but .update() actually returns an integer
count of updated rows.

The caller in scanpipe/pipes/scancode.py already re-filters manually:
    resource_qs.filter(~Q(status=flag.IGNORED_BY_MAX_FILE_SIZE))
proving the original return value was misleading.

Fix: explicitly return the flagged_count integer and update the
docstring to accurately describe the return value.

Add regression tests to verify the return type and that files
are correctly flagged with IGNORED_BY_MAX_FILE_SIZE status.

Signed-off-by: Prajakta Kamble <prajuu2812@gmail.com>
@prajakta128 prajakta128 force-pushed the fix/flag-and-ignore-files-over-max-size-return-value branch from cd2a7aa to 4cd77ad Compare June 26, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant