Back to Intellij Community

AssertWithSideEffects

java/java-impl/resources/inspectionDescriptions/AssertWithSideEffects.html

2025.3-rc-2366 B
Original Source

Reports assert statements that cause side effects.

Since assertions can be switched off, these side effects are not guaranteed, which can cause subtle bugs. Common unwanted side effects detected by this inspection are modifications of variables and fields. When methods calls are involved, they are analyzed one level deep.

Example:

assert i++ < 10;