Repository navigation
ci(qodo): add optional chaining compliance rule - #12255
pkuczynski wants to merge 3 commits into
Conversation
Review Summary by QodoAdd optional chaining compliance rule to Qodo checklist
WalkthroughsDescription• Add optional chaining compliance rule to Qodo checklist • Catches non-null assertion issues before SonarQube quality gate • Aligns with TypeScript best practices for null safety Diagramflowchart LR
A["PR Compliance Checklist"] -->|adds new rule| B["Optional Chaining Rule"]
B -->|objective| C["Use ?. instead of !"]
B -->|success| D["expect().to.not.be.null + ?.property"]
B -->|failure| E["result!.property usage"]
File Changes1. pr_compliance_checklist.yaml
|
Code Review by Qodo
1.
|
Should we also then remove https://github.com/typeorm/typeorm/blob/master/pr_compliance_checklist.yaml#L14-L18? And how would you like to implement in eslint a check where in the test (only!) we should first assert for not null, and then use optional chaining? I really want to see an example of such config... |
Review Summary by QodoAdd optional chaining compliance rule to Qodo checklist
WalkthroughsDescription• Add optional chaining compliance rule to Qodo checklist • Catches non-null assertion issues before SonarQube quality gate • Promotes safer TypeScript patterns in test code Diagramflowchart LR
A["PR Compliance Checklist"] -->|adds new rule| B["Optional Chaining Rule"]
B -->|objective| C["Use ?. instead of !"]
B -->|success criteria| D["expect().to.not.be.null + optional chaining"]
B -->|failure criteria| E["Non-null assertions detected"]
File Changes1. pr_compliance_checklist.yaml
|
|
Persistent review updated to latest commit d731fae |
|
How about eslint: Normally we would add the entire config at once (@typescript-eslint/stylistic-type-checked), but our code base might not be there yet (the internal types are not always correct, so some rule that might be stylistic based on the type information, could end up breaking functionality) I also noticed there's a lot of Sonar also complains quite a lot about unnecessary type assertions, e.g.
That would great, that Qodo rule is so generic that I doubt is of any use. "project's established naming standards" - what's that mean? They are not described anywhere.
|
Deploying typeorm with
|
| Latest commit: |
e8e4aa9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://73271202.typeorm.pages.dev |
| Branch Preview URL: | https://chore-optional-chaining-comp.typeorm.pages.dev |
|
Persistent review updated to latest commit e8e4aa9 |
…t both null-check styles
|
|
Persistent review updated to latest commit b0a81dc |
|
I've been enabling these rules incrementally in separate PRs:
I also tackled the non-null assertion issue from SonarQube by replacing Closing in favor of the PRs above. |



Add a Qodo compliance check for preferring optional chaining (
?.) over non-null assertions (!) in tests after null checks.SonarQube frequently flags non-null assertions as unnecessary type assertions (
typescript:S4325). Adding this to the Qodo checklist catches it earlier during PR review, before it reaches the SonarQube quality gate.