rspec/rules/S4972/swift/rule.adoc

72 lines
1.4 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
When a method doesn't match it's ``++super++`` method in visibility (``++public++``, ``++protected++``, ...), malicious callers could take advantage of the over-broad access offered by the child class to undermine the application.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
public class Parent {
protected void foo() {
//...
}
}
public class Child extends Parent {
public void foo() { // Noncompliant
// ...
super.foo();
}
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,swift]
2021-04-28 16:49:39 +02:00
----
public class Parent {
protected void foo() {
//...
}
}
public class Child extends Parent {
protected void foo() {
// ...
super.foo();
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Decrease the accessibility of this method to "xxx" to match the parent class implementation.
=== Highlighting
* visibility modifier
'''
== Comments And Links
(visible only on this page)
=== on 31 Oct 2018, 11:57:13 Tibor Blenessy wrote:
This rule was forked from RSPEC-3551 to allow RSPEC-3551 to focus only on synchronization which is Java specific concept and real bug. I am actually not really sure about the value of this rule, that's why it is not included in the default profile. However, I am really sure about the value of RSPEC-3551 so I wanted to remove this fuzzy part from it.
endif::env-github,rspecator-view[]