
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
56 lines
1.7 KiB
Plaintext
56 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
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)
|
|
|
|
=== Message
|
|
|
|
Remove this call to "xxx"; it will return an "UnsupportedOperationException".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 22 Oct 2014, 19:11:57 Nicolas Peru wrote:
|
|
Scope of the rule is really important here:
|
|
|
|
We don't have interprocedural analysis so, we can't actually analyze what is the implementation of a remote method call.
|
|
|
|
|
|
So what's left : implementation of call to methods declared within the same class, but then you would raise issue exactly because you are calling a method that is supposed to be overidden in inherited classes.
|
|
|
|
|
|
So I don't see how we can actually deal with this rule.
|
|
|
|
endif::env-github,rspecator-view[]
|