Skip to content

Fix: react hook hidden mutation noise - #73

Merged
alxxjohn merged 5 commits into
mainfrom
fix/react-hook-hidden-mutation-noise
Jul 28, 2026
Merged

Fix: react hook hidden mutation noise#73
alxxjohn merged 5 commits into
mainfrom
fix/react-hook-hidden-mutation-noise

Conversation

@alxxjohn

Copy link
Copy Markdown
Contributor

PR Summary

This PR hardens CodeGuard’s precision around high-volume false positives seen while dogfooding against TypeScript/JavaScript React/Next codebases.

Key changes:

  • Reduces function.hidden-mutation noise for React hooks, local builders, collectors, accumulators, script entrypoints, and Next route handlers.

  • Keeps real hidden side effects detectable, including collaborator mutations like repo.save(...), parameter mutation, and external resource
    mutation.

  • Recognizes common command/event-style names such as submit, upload, download, notify, fetch, list, read, exists, seed, apply, sync, approve, and
    related verbs.

  • Hardens quality.ambiguous-name for conventional UI/render-prop names like value, values, item, items, and data in React/UI callback contexts.

  • Prevents function.command-query-mix from flagging React components/hooks and framework-required Next GET / POST handlers.

  • Improves quality.duplicated-knowledge by including the duplicated literal in the finding message and skipping obvious UI display/class strings.

  • Tightens naming.cardinality-mismatch to require stronger type evidence and ignore common framework names like args, props, searchParams, next,
    out, ids, and rows.

  • Prevents quality.mutable-global-state from misclassifying local React/component bindings as module-level mutable state.

  • Allows common UI boolean prop names like open, loading, active, and pending in React/UI contexts for naming.boolean-not-predicate.

  • Refines design.persistence-model-leak so generated Prisma enum imports and TypeScript Record<...> utility types are not treated as ORM model
    leaks.

Tests added/updated:

  • React hook hidden-mutation regression coverage.
  • Cross-language local mutation coverage for TS, JS, Python, Go, and C++.
  • Next route handler and script entrypoint coverage.
  • UI false-positive coverage for ambiguous names, boolean names, mutable globals, cardinality naming, duplicated literals, command-query mix, and
    Prisma enum imports.

Validation:

go test ./...
make codeguard-ci

Both pass.

@alxxjohn
alxxjohn merged commit 3fa1b1c into main Jul 28, 2026
16 checks passed
@alxxjohn
alxxjohn deleted the fix/react-hook-hidden-mutation-noise branch July 28, 2026 00:12
alxxjohn added a commit that referenced this pull request Jul 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.3.1](v1.3.0...v1.3.1)
(2026-07-28)


### Bug Fixes

* harden hidden mutation precision
([8f77a74](8f77a74))
* harden UI false positive precision
([b46dfe7](b46dfe7))
* react hook hidden mutation noise
([#73](#73))
([3fa1b1c](3fa1b1c))
* reduce hidden mutation noise for React hooks
([c4f61c9](c4f61c9))
* satisfy lint for false positive hardening
([62643da](62643da))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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