feat(rust): count ? try operator in complexity#701
Merged
boyter merged 5 commits intoboyter:masterfrom May 4, 2026
Merged
Conversation
Contributor
daulet
commented
Apr 23, 2026
There was a problem hiding this comment.
Pull request overview
Adds support for counting Rust’s postfix ? try operator toward cyclomatic complexity by introducing a new “postfix complexity token” mechanism in the processor, and wiring it through the language definitions pipeline (JSON → generated constants → runtime token tries).
Changes:
- Extend language definitions to support
complexitychecks_postfix(JSON + generator template + Go structs/constants). - Add a new token type (
TComplexityPostfix) and matching logic in the hot-path tokenizer/state machine. - Add Rust-specific tests to verify
?is counted while?Sizedis not.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/languages.tmpl | Generate ComplexityChecksPostfix into languageDatabase when present. |
| languages.json | Add Rust complexitychecks_postfix: ["?"]. |
| processor/constants.go | Generated update: Rust now includes ComplexityChecksPostfix: []string{"?"}. |
| processor/structs.go | Add TComplexityPostfix and extend Language with ComplexityChecksPostfix. |
| processor/processor.go | Insert postfix complexity tokens into the token trie and process mask. |
| processor/workers.go | Implement counting logic for TComplexityPostfix and add isIdentifierStart helper. |
| processor/workers_test.go | Add tests for Rust ? counting and ?Sized non-counting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apocelipes
suggested changes
Apr 24, 2026
apocelipes
reviewed
Apr 24, 2026
Owner
|
Thanks for this. This is one of those ones I have wanted for a while but never tackled... probably because I dont do much rust. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.