rspec/rules/S927/dart/rule.adoc

40 lines
1.3 KiB
Plaintext

:compliantCode: compliant-code.adoc
:noncompliantCode: noncompliant-code.adoc
:doc: https://dart.dev/tools/dart-doc
== Why is this an issue?
Parameters are part of the method signature and its identity.
Overriding a method and changing one of its parameters' names will confuse and impact the method's readability. In {doc}[dart doc] the consequences might be even worse. If an overriding method doesn't provide ots own documentation comment, it will inherit a comment from an overridden method. If the inherited comment contains a link to the parameter, which was renamed, linking will fail.
include::{noncompliantCode}[]
To avoid any ambiguity in the code, a parameter's name should match the initial declaration, whether its initial declaration is from an interface, a base class, or a partial method.
include::{compliantCode}[]
== Resources
=== Documentation
* Dart Docs - https://dart.dev/tools/linter-rules/avoid_renaming_method_parameters[Dart Linter rule - avoid_renaming_method_parameters]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* "The parameter name '{}' doesn't match the name '{}' in the overridden method"
=== Highlighting
The parameter name of the overriding method.
'''
endif::env-github,rspecator-view[]