- changed status to open
If statement intentions/inspections
Issue #2562
open
I’d really like to see inspections ported from other IDEA languages:
- Invert If condition
- Remove Redundant Else
These inspections would allow the following code
Integer calculate(Integer bottom, Integer top) {
if (top > bottom) {
Integer sum = 0;
for (Integer number = 0; number <= top; number++) {
if (number % 2 == 0) {
sum += number;
}
}
return sum;
} else {
return 0;
}
}
To be translated to the following using the inspections one after another:
Integer calculate(Integer bottom, Integer top) {
if (top <= bottom) {
return 0;
}
Integer sum = 0;
for (Integer number = 0; number <= top; number++) {
if (number % 2 == 0) {
sum += number;
}
}
return sum;
}
Comments (2)
-
repo owner -
repo owner - removed version
- Log in to comment
Yup, I use these all the time in Java and was just thinking myself that they would be equally useful in Apex. In fact, the one that I use most often isn't even on your list, specifically the ability to split an
if
statement with multiple conjoined condiitons into multipleif
statements, and conversely, the ability to join nestedif
(orelse
with nestedif
) statements when there isn't other logic in that block.It's on the backlog -- and part of my personal interest -- but not sure when it'll get full attention.