-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lint] avoid_unused_parameters #59955
Comments
Just to make sure we have covered the details, I guess this rule should not apply when you override a method? What about scenarios where we have a default implementation not using the parameter but we want the parameter to be available for sub-classes? |
yes is this a valid design to have unused parameters for people who might extend you? |
top-level function and static function, this linter will always make sense right? |
It is reasonable to have unused parameters for a method of the base class. The Template Method Pattern may involve defining methods in a base class with unused parameters. The idea is that the base class provides a partial implementation using some parameters and the extenders can make use of that implementation by calling super while also adding implementation involving the unused parameters. class ErrorProcessor
{ void process({required String severity, required String message, Object? error})
{ print('[$severity] $message');//<Parent class implements logging
}
}
final class DatabaseErrorProcessor extends ErrorProcessor
{ @override void process({required String severity, required String message, Object? error})
{ super.process(severity: severity, message: message, error: error);//<Allow parent processing to occur
//<Can make decisions of other things to do based on the error, like
// attempting recovery
}
} |
@RohitSaily I would be happy personally with false positive on that case and the need to explicitly say these parameters are meat for extenders by silencing the linter there. |
I agree. I think it is better to have it cautious by default because, as you have said, the linter can be silenced when it is intentional design. |
uselessbool
is an unused parametersThe text was updated successfully, but these errors were encountered: