Modify rule S1161: "@override" should be used on overriding members (annotate_overrides)
This commit is contained in:
parent
b70eb0aed1
commit
a9dbd9f246
2
rules/S1161/comments-and-links.adoc
Normal file
2
rules/S1161/comments-and-links.adoc
Normal file
@ -0,0 +1,2 @@
|
||||
=== on 29 Jul 2013, 15:51:56 Freddy Mallet wrote:
|
||||
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-249
|
@ -1,7 +1,8 @@
|
||||
== Why is this an issue?
|
||||
|
||||
While not mandatory, using the `@Override` annotation on compliant members improves readability by making it explicit that members are overridden.
|
||||
While not mandatory, using the https://api.dart.dev/dart-core/override-constant.html[`@override`] annotation on compliant members (methods, properties, operators) improves readability by making it explicit that members are overridden.
|
||||
|
||||
Unlike other languages, all methods in Dart are https://en.wikipedia.org/wiki/Virtual_function[`virtual`] by default. So, using the `@override` annotation prevents accidental overriding of a base class method in a subclass.
|
||||
|
||||
=== Noncompliant code example
|
||||
|
||||
@ -31,4 +32,31 @@ class FirstChildClass extends ParentClass {
|
||||
|
||||
== Resources
|
||||
|
||||
* https://dart.dev/tools/linter-rules/annotate_overrides[Dart Lint rule]
|
||||
* Dart Docs - https://dart.dev/tools/linter-rules/annotate_overrides[Dart Linter rule - annotate_overrides]
|
||||
* Dart Docs - https://dart.dev/language/extend#overriding-members[Extend a class - Overriding members]
|
||||
* Dart API Reference - https://api.dart.dev/dart-core/override-constant.html[Override top-level constant]
|
||||
* Wikipedia - https://en.wikipedia.org/wiki/Virtual_function[Virtual function]
|
||||
|
||||
ifdef::env-github,rspecator-view[]
|
||||
|
||||
'''
|
||||
== Implementation Specification
|
||||
(visible only on this page)
|
||||
|
||||
=== Message
|
||||
|
||||
The member '<method name>' overrides an inherited member but isn't annotated with '@override'.
|
||||
|
||||
If the member is a setter, the method name will end with a `=` sign, to distinguish it from the corresponding getter.
|
||||
|
||||
=== Highlighting
|
||||
|
||||
The identifier of the method, property or operator.
|
||||
|
||||
'''
|
||||
== Comments And Links
|
||||
(visible only on this page)
|
||||
|
||||
include::../comments-and-links.adoc[]
|
||||
|
||||
endif::env-github,rspecator-view[]
|
||||
|
@ -52,7 +52,6 @@ Add the "@Override" annotation above this method signature
|
||||
== Comments And Links
|
||||
(visible only on this page)
|
||||
|
||||
=== on 29 Jul 2013, 15:51:56 Freddy Mallet wrote:
|
||||
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-249
|
||||
include::../comments-and-links.adoc[]
|
||||
|
||||
endif::env-github,rspecator-view[]
|
||||
|
Loading…
x
Reference in New Issue
Block a user