rspec/rules/S1199/java/rule.adoc

52 lines
800 B
Plaintext
Raw Normal View History

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,java]
----
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
2022-02-04 17:28:24 +01:00
[source,java]
----
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[]
'''
== 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[]