Skip to content

fix: don't flag comprehension predicates#43

Merged
nextchamp-saqib merged 1 commit into
frappe:developfrom
nextchamp-saqib:fix/has-permission-comprehension-fp
Jun 5, 2026
Merged

fix: don't flag comprehension predicates#43
nextchamp-saqib merged 1 commit into
frappe:developfrom
nextchamp-saqib:fix/has-permission-comprehension-fp

Conversation

@nextchamp-saqib

@nextchamp-saqib nextchamp-saqib commented Jun 5, 2026

Copy link
Copy Markdown
Member

unchecked-frappe-permission-call flags discarded frappe.has_permission calls by listing the contexts where the value is used (assign/return/if/ternary/assert). Comprehension predicates are missing, so this false-positives:

permitted = [d for d in doctypes if frappe.has_permission(d, "read")]

Adds pattern-not-inside exclusions for list/set/dict comprehensions + generators (deep-expr operator, so negated predicates count), and adds the rule's first fixtures. make test → 29/29 ✓.

…cates

`unchecked-frappe-permission-call` detects a discarded `frappe.has_permission`
return value by enumerating the "value is used" contexts (assignment, return,
if, ternary, assert). Using the call as a comprehension predicate isn't in that
list, so a perfectly safe filter is flagged as a false positive:

    permitted = [d for d in doctypes if frappe.has_permission(d, "read")]

Add pattern-not-inside exclusions for list/set/dict comprehensions and
generator expressions, and add test fixtures for this rule (there were none),
covering both the discarded-call case (still fires) and the use-as-predicate
cases (no longer fire).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nextchamp-saqib nextchamp-saqib changed the title fix(unchecked-frappe-permission-call): don't flag comprehension predicates fix: don't flag comprehension predicates Jun 5, 2026
@nextchamp-saqib
nextchamp-saqib merged commit 3011799 into frappe:develop Jun 5, 2026
1 check 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.

1 participant