Inspectopedia Help

'assert' message is not a string

Reports assert messages that are not of the java.lang.String type.

Using a string provides more information to help diagnose the failure or the assertion reason.

Example:

void foo(List<Integer> myList) { assert myList.isEmpty() : false; }

Use the Only warn when the assert message type is 'boolean' or 'java.lang.Boolean' option to only warn when the assert message type is boolean or java.lang.Boolean. A boolean detail message is unlikely to provide additional information about an assertion failure and could result from a mistakenly entered : instead of &.

Inspection options

Option

Type

Default

Only warn when 'assert' message is 'boolean' or 'java.lang.Boolean'

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023