Where is an inspection to trigger on "null != foo"?

Which of the eleventy-hundred-sixty-five inspections can trigger if null is on the left side of a comparison?

"Constant on left side of comparison" does not trigger.

0
3 comments
Avatar
Permanently deleted user

Hello Stephen,

Stephen Friedrich wrote:

Which of the eleventy-hundred-sixty-five inspections can trigger if
null is on the left side of a comparison?


The Structural Search Inspection:-)

"Constant on left side of comparison" does not trigger.


Technically null is not a compile-time constant, therefore this
inspection does not trigger on it. I suppose I could add an option to
the inspection to check null too, if you have a good enough reason.
Please submit a JIRA issue.

Bas

0
Avatar
Permanently deleted user

Why do you need such an inspection?

It is very useful to put the constants like null to the left side.

0

i always put constants on the right side. probably for the same reason as yours, just the other way round (i think your way of thinking is weird^^ - i want to know which variable is checked first, and then i want to know what condition it has to fulfill. let's say i have 200 if else if else if, having the same constant on the left side gives me a lot less information than having a variable on the left side.)

i'll vote for that jira request if it includes the text "this should work for the opposite way as well" somewhere.

Message was edited by:
HamsterofDeath

0

Please sign in to leave a comment.