rspec/rules/S2120/java/rule.adoc
2022-02-04 16:28:24 +00:00

41 lines
1.1 KiB
Plaintext

There are several reasons that a class might have a method that throws an ``++UnsupportedOperationException++``. The method may be required by an interface or an abstract superclass but not actually needed in the class. Or it may be that the class itself is intended as a superclass, and the method may optionally be implemented by subclasses but not invoked on the superclass. Finally, it could be that the method has been stubbed into the code but not implemented yet.
Whatever the reason, methods that throw ``++UnsupportedOperationException++`` should not be called.
== Noncompliant Code Example
[source,java]
----
public class Callee {
public int doTheThing() {
throw new UnsupportedOperationException("Not implemented");
}
}
public class Caller {
public void accomplishStuff() {
//...
Callee callee = new Callee();
callee.doTheThing(); // Noncompliant
----
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[]