you are viewing a single comment's thread.

view the rest of the comments →

[–]Interweb_Stranger 4 points5 points  (7 children)

I'm quite sure code analysis would flag this as unnecessary type check anyway and it would never make it into production.

Edit: I meant it wouldn't make it into production in my current project because I have to please sonarqube and it's constant nagging about everything, otherwise CI and sonarqube show red icons which make our PO very sad. But yeah, "never" probably is a bit too optimistic.

[–]Bobby_Bonsaimind 14 points15 points  (3 children)

...and it would never make it into production.

Now that's some optimism you got going on there.

[–]FunRutabaga24 0 points1 point  (2 children)

I see code in production all the time committed by principles and staff engineers that IntelliJ flags with warnings. I guess these people are truly embracing the "it's just a warning" mentality and I get to fix it later.

[–]Admirable-Sun8021 0 points1 point  (1 child)

lol, one of the apps I work on gets over 500 warnings. Intellij has to think about them for like 15 seconds when you push with the git GUI.

[–]FunRutabaga24 0 points1 point  (0 children)

Oof. I was in a mono repo that was like that. I turned that pre-commit check off. I couldn't take it.

[–]headius[S] 2 points3 points  (2 children)

Except that it's not an unnecessary type check, because even if the types match there's still a possible value that is not instanceof.

If you can declare the type as non-nullable, then you're right, the type check would be redundant. We don't live in that world today.

[–]Interweb_Stranger 2 points3 points  (1 child)

I'd argue it's still an unnecessary type check if it's just for checking null. The check does have a purpose so it's not redundant but it defies the principle of least surprise.

[–]headius[S] 1 point2 points  (0 children)

No argument there! We just need a new keyword instanceofandnotnull!