- What language is this for?
Java - Which rule?
java:S5838 - Using SonarCloud
java:S5838 contains a lot of subrules, and I would like to exclude on of them, but currently it is not possible.
The rule I want to configure is the following one:
assertThat(myVar).isGreaterThanOrEqualTo(1);
Sonar suggest to use isPositive()
instead.
I would like to avoid that for the following reasons:
- it increases the cognitive burden, as it forces the reader to ask themself if 0 is positive to understand the comparison (note that this convention depends on the field and the context: algebra precalculus - Is zero positive or negative? - Mathematics Stack Exchange, but that’s an issue with assertj itself)
- it does not improve readability, as it may break the alignment when there are several comparisons in a row:
assertThat(myVar3).isGreaterThanOrEqualTo(3);
assertThat(myVar2).isGreaterThanOrEqualTo(2);
assertThat(myVar1).isGreaterThanOrEqualTo(1);