Skip to content

Fix flag_and_ignore_files_over_max_size inconsistent return value and docstring#2184

Merged
tdruez merged 6 commits into
aboutcode-org:mainfrom
prajakta128:fix/flag-and-ignore-files-over-max-size-return-value
Jul 10, 2026
Merged

Fix flag_and_ignore_files_over_max_size inconsistent return value and docstring#2184
tdruez merged 6 commits into
aboutcode-org:mainfrom
prajakta128:fix/flag-and-ignore-files-over-max-size-return-value

Conversation

@prajakta128

Copy link
Copy Markdown
Contributor

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
@prajakta128

Copy link
Copy Markdown
Contributor Author

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!

tdruez added 5 commits July 10, 2026 09:58
Signed-off-by: tdruez <489057+tdruez@users.noreply.github.com>
Signed-off-by: tdruez <489057+tdruez@users.noreply.github.com>
Signed-off-by: tdruez <489057+tdruez@users.noreply.github.com>
Signed-off-by: tdruez <489057+tdruez@users.noreply.github.com>
Signed-off-by: tdruez <489057+tdruez@users.noreply.github.com>
@tdruez tdruez merged commit 5cfe7e1 into aboutcode-org:main Jul 10, 2026
8 checks passed
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.

2 participants