git commit -m "Fix provider_parameters false positive for extension t…#4804
git commit -m "Fix provider_parameters false positive for extension t…#4804agarwalrahul2702 wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughModifies the ChangesExtension Type False-Positive Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/riverpod_lint/lib/src/lints/provider_parameters.dart (1)
78-90: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
returninside the loop skips checking remaining arguments.Line 83's
if (instantiatedType is ExtensionTypeElement) return;exits the entire_checkExpressionmethod, not just the current loop iteration. If a provider takes multiple parameters (e.g. a tuple/family with several arguments) and an earlier argument happens to be an extension type, every subsequent argument inarguments.argumentsis silently skipped — even ones that should be flagged (e.g. a non-const list literal). This should becontinueto only skip the current argument's check.🐛 Proposed fix
} else if (value is InstanceCreationExpression && !value.isConst) { final instantiatedObject = value.constructorName.element ?.applyRedirectedConstructors(); final instantiatedType = instantiatedObject?.enclosingElement; - if (instantiatedType is ExtensionTypeElement) return; + if (instantiatedType is ExtensionTypeElement) continue; final operatorEqual = instantiatedType?.recursiveGetMethod('==');The added tests only cover single-argument
legacy(TypeId(1))/generatorProvider(value: TypeId(1))calls, so this multi-argument regression isn't caught by the new coverage.🤖 Prompt for 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. In `@packages/riverpod_lint/lib/src/lints/provider_parameters.dart` around lines 78 - 90, The early exit in `_checkExpression` should not stop evaluation of the rest of `arguments.arguments` when an `InstanceCreationExpression` resolves to an `ExtensionTypeElement`. Replace the `return` after the `instantiatedType is ExtensionTypeElement` check with `continue` so only that argument is skipped, and keep the existing `operatorEqual`/`rule.reportAtNode` logic running for any remaining arguments in the loop.
🤖 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.
Outside diff comments:
In `@packages/riverpod_lint/lib/src/lints/provider_parameters.dart`:
- Around line 78-90: The early exit in `_checkExpression` should not stop
evaluation of the rest of `arguments.arguments` when an
`InstanceCreationExpression` resolves to an `ExtensionTypeElement`. Replace the
`return` after the `instantiatedType is ExtensionTypeElement` check with
`continue` so only that argument is skipped, and keep the existing
`operatorEqual`/`rule.reportAtNode` logic running for any remaining arguments in
the loop.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b92b3c05-ba7a-4473-b72c-a5214d317cd4
📒 Files selected for processing (3)
packages/riverpod_lint/CHANGELOG.mdpackages/riverpod_lint/lib/src/lints/provider_parameters.dartpackages/riverpod_lint_flutter_test/test/lints/provider_parameters.dart
Related Issues
fixes #4796
Checklist
CHANGELOG.mdof the relevant packages.I have updated the documentation to match those changes.
Summary by CodeRabbit
Bug Fixes
provider_parameterslint when using extension type arguments.Tests