feat(lints): Reject hard-coded GTS ID prefixes#81
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
🚧 Files skipped from review as they are similar to previous changes (13)
📝 WalkthroughWalkthroughAdds DE0904, a deny-level pre-expansion lint that detects hard-coded ChangesDE0904 lint
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant RustCompiler
participant De0904NoHardcodedGtsPrefix
participant source_contains_hardcoded_prefix
participant emit_lint
RustCompiler->>De0904NoHardcodedGtsPrefix: run pre-expansion checks
De0904NoHardcodedGtsPrefix->>source_contains_hardcoded_prefix: inspect attribute or macro span
source_contains_hardcoded_prefix-->>De0904NoHardcodedGtsPrefix: return prefix match
De0904NoHardcodedGtsPrefix->>emit_lint: report matching literal or span
emit_lint-->>RustCompiler: emit DE0904 deny diagnostic
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@crates/cargo-gears-lints/src/de09_gts_layer/de0904_no_hardcoded_gts_prefix.rs`:
- Around line 4-103: Refactor De0904NoHardcodedGtsPrefix to implement check_expr
and check_mac_call directly, preserving the existing literal and source-prefix
detection behavior. Remove HardcodedPrefixVisitor, check_item, manual AST
walking, lint_once, and the LINTED_SPANS thread-local state; report directly
through span_lint_and_then from each EarlyLintPass callback while retaining
ordinary-attribute handling in check_attribute.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: be690f0d-224f-44a1-9ad0-4ffea3042c3d
📒 Files selected for processing (14)
crates/cargo-gears-lints/Cargo.tomlcrates/cargo-gears-lints/README.mdcrates/cargo-gears-lints/docs/README.mdcrates/cargo-gears-lints/docs/de09_gts_layer/de0904_no_hardcoded_gts_prefix/README.mdcrates/cargo-gears-lints/src/de09_gts_layer/de0904_no_hardcoded_gts_prefix.rscrates/cargo-gears-lints/src/lib.rscrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/gts_id_marker.rscrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/hardcoded_prefix.rscrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/hardcoded_prefix.stderrcrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/hardcoded_prefix_in_attributes.rscrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/hardcoded_prefix_in_attributes.stderrcrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/hardcoded_prefix_in_macros.rscrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/hardcoded_prefix_in_macros.stderrcrates/cargo-gears-lints/tests/ui/de0904_no_hardcoded_gts_prefix/macro_markers.rs
- Add the DE0904 pre-expansion lint for literal prefixes in expressions, macro invocations, and attributes. - Document the rule and cover valid gts_id! usage alongside UI failures. Signed-off-by: Vasily Tsybenko <Vasily.Tsybenko@acronis.com>
50655e0 to
65b963a
Compare
Summary by CodeRabbit
gts.prefixes when they appear in string literals, macro inputs, and attribute values.gts_id!("<suffix>").concat!, macros, attributes) and marker-based usage that should not be rejected.