Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:* Decrease the accessibility of this method to "xxx" to match the parent class implementation.
-
Highlighting:
- visibility modifier
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Targeted languages:Swift
-
Remediation Function:Constant/Issue
-
Constant Cost:20min
-
CERT:MET04-J.
-
SwiftLint:no_extension_access_modifier
Description
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
public class Parent { protected void foo() { //... } } public class Child extends Parent { public void foo() { // Noncompliant // ... super.foo(); } }
Compliant Solution
public class Parent { protected void foo() { //... } } public class Child extends Parent { protected void foo() { // ... super.foo(); } }
See
- CERT, MET04-J. - Do not increase the accessibility of overridden or hidden methods
Attachments
Issue Links
- is implemented by
-
SONARJAVA-3013 Rule S4972: Overrides should match their parent class methods in visibility
-
- Closed
-