rspec/rules/S3054/java/rule.adoc

47 lines
887 B
Plaintext

== Why is this an issue?
Each constructor must first invoke a parent class constructor, but it doesn't always have to be done explicitly. If the parent class has a reachable, no-args constructor, a call to it will be inserted automatically by the compiler. Thus, calls to ``++super()++`` can be omitted.
=== Noncompliant code example
[source,java]
----
public class MyClass {
private Foo foo;
public MyClass (Foo foo) {
super(); // Noncompliant
this.foo = foo;
}
----
=== Compliant solution
[source,java]
----
public class MyClass {
private Foo foo;
public MyClass (Foo foo) {
this.foo = foo;
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]