Skip to content

feat(rules,allowlist): exclude Cargo test/benchmark paths and refine Rust rules - #1971

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
alex09x:feat/go-mod-and-rust-test-rules
Nov 21, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
alex09x:feat/go-mod-and-rust-test-rules

Conversation

@alex09x

@alex09x alex09x commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

What was wrong

default_exclude_patterns.json only listed **/*_test.rs for Rust, so standard Cargo integration tests (tests/**/*.rs), module test files (tests.rs, *_tests.rs), and benchmarks (benches/**/*.rs) were reviewed as production code against rust.md (accounting for 56%, 30%, and 24% of reviewed insertions across three multi-file Rust commits we tested).

What this PR changes

  • Add **/*_tests.rs, **/tests.rs, **/tests/**/*.rs, and **/benches/**/*.rs to internal/config/allowlist/default_exclude_patterns.json (and the localized review-rules.md docs).
  • Add the precision-first and tool-verification preamble to internal/config/rules/rule_docs/rust.md, matching go.md and swift.md.
  • Add unit tests for the new Cargo test and benchmark exclude patterns in internal/config/allowlist, internal/agent, and internal/scan.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally

  • Manual testing (describe below)

  • Ran bash scripts/verify-license.sh, git diff origin/main --check, LC_ALL=C go vet $(go list ./... | grep -v /extensions/), and LC_ALL=C go test -race -count=1 ./internal/config/allowlist ./internal/config/rules ./internal/agent ./internal/scan.

  • Ran LC_ALL=C go test -count=1 -coverprofile=coverage.out $(go list ./... | grep -v /extensions/): 25 of 26 packages passed (allowlist 92.3%, rules 92.5%, agent 91.4%, scan 93.1%); TestPendingLoginConcurrentAccountOperations/return-login in internal/chatgptauth (untouched by this PR) timed out on our test host. Re-running with -skip "^TestPendingLoginConcurrentAccountOperations/return-login$" passed all 26 packages with 93.0% total statement coverage.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Used Google Antigravity (Gemini) and Claude Code.

Related Issues

Closes #1970

@CLAassistant

CLAassistant commented Nov 17, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 6 selected item(s).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't consider support go.mod because it is a package lock generated by Go, it doesn't need to be reviewed. You can keep the Cargo test exclusion though.

@alex09x alex09x changed the title feat(rules,allowlist): support go.mod/go.work review and Cargo test exclusions feat(rules,allowlist): exclude Cargo test/benchmark paths and refine Rust rules Nov 20, 2026
@alex09x
alex09x force-pushed the feat/go-mod-and-rust-test-rules branch from 6d8cf66 to 9b8f85f Compare November 20, 2026 00:22

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 7e4ecad into alibaba:main Nov 21, 2026
15 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.

feat(rules,allowlist): support go.mod/go.work review and Cargo test path conventions

4 participants