Pointless boolean expression inspection (aka GroovyPointlessBoolean) in Spock tests broken in IntelliJ IDEA
When writing a data driven table test in Spock where my result is a simple boolean true or false, I discovered that IntelliJ IDEA runs an inspection and decides that the code can be simplified by simply removing the result value. This means it wants to take a result data table that looks like this:
And make it look like this:
Unfortunately, this solution also causes the code to not compile.
The only solution seems to be to either ignore the warning and let the little yellow box remain yellow or to disable this inspection entirely within IntelliJ IDEA. I chose the latter, and disabled it only within Groovy. I really like code inspections, and I hate losing this static analysis, but sometimes there are just certain checks that get a bit confused.
where:
checkpoint || result
"2018-10-22" || false
And make it look like this:
where:
checkpoint || result
"2018-10-22" ||
After allowing this inspection to make a change, the test will no longer run. IntelliJ offers the option to ignore this inspection at the method or class level with an annotation:@SuppressWarnings("GroovyPointlessBoolean")
Unfortunately, this solution also causes the code to not compile.
The only solution seems to be to either ignore the warning and let the little yellow box remain yellow or to disable this inspection entirely within IntelliJ IDEA. I chose the latter, and disabled it only within Groovy. I really like code inspections, and I hate losing this static analysis, but sometimes there are just certain checks that get a bit confused.
Comments
Post a Comment