rspec/rules/S1199/java/rule.adoc

40 lines
649 B
Plaintext
Raw Normal View History

include::../description.adoc[]
== Noncompliant Code Example
----
public void evaluate(int operator) {
// Do some computation...
{
int a = stack.pop();
int b = stack.pop();
int result = a + b;
stack.push(result);
}
}
----
== Compliant Solution
----
public void evaluate(int operator) {
// Do some computation...
evaluateAdd();
}
private void evaluateAdd() {
int a = stack.pop();
int b = stack.pop();
int result = a + b;
stack.push(result);
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]