In SonarQube version 8.9.1 it appears like the rule about preferring the pre-increment over the post increment operator described here Rules explorer, detects any and all usages of the operator.
It seems a little too strict, because in some situations where the returned value is used, avoiding it is noisy. Syntactically it would make sense if the rule would trigger in the same cases where a compilation warning would be issued if the post-increment operator was declared with [[nodiscard]]
.
And indeed, the wording of this rule says that one should prefer to replace the post-increment with pre-increment, not that the post-increment should be avoided at all cost.
Case in point is something like this:
const int someValue = iter != vec.end() ? *iter++ : 0;