fix(restrict-template-expressions): allow inherited types in allow list#804
Conversation
How to use the Graphite Merge QueueAdd the label 0-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR fixes the restrict-template-expressions rule to allow types that inherit from types listed in the allow option. Previously, only an exact type match was checked against the allow list; now the rule walks the inheritance chain using MatchesTypeOrBaseType, so a derived class or interface is accepted if any of its base types match a specifier in the allow list.
Changes:
- Wrapped the
TypeMatchesSomeSpecifiercall withMatchesTypeOrBaseTypeto recursively check base types against the allow list. - Added three valid test cases covering single-level class inheritance, multi-level class inheritance, and interface inheritance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/rules/restrict_template_expressions/restrict_template_expressions.go |
Wraps the allow-list type check with MatchesTypeOrBaseType to match inherited types |
internal/rules/restrict_template_expressions/restrict_template_expressions_test.go |
Adds three valid test cases for class and interface inheritance scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
93080ba to
49289b5
Compare
fe97c74 to
e04113f
Compare
e04113f to
16b3b4e
Compare
49289b5 to
89fca42
Compare
89fca42 to
f96d5e9
Compare
Merge activity
|
f96d5e9 to
2617074
Compare

No description provided.