r/badcode • • May 12 '23

java Code written by project lead. A comment was added by my team member that the entire method can be replaced with a single line: getErrorsList().contains(message). Project lead responded that we should focus on readability and performance and not on such code review comments.

Post image
796 Upvotes

152 comments sorted by

View all comments

42

u/[deleted] May 12 '23

That does not even compile so it’s bullshit.

85

u/sausage-x-donut May 12 '23

Apologies, I was editing it to remove any additional information and must have missed the '='

List<String> errorsList = getErrorsList();

-47

u/[deleted] May 12 '23

In my newest project we use PWD, Sonar etc and these things would just block the build :)

64

u/degaart May 12 '23

It's java so any syntax error would "block the build".

-12

u/[deleted] May 12 '23 edited May 12 '23

Ignoring that, which is an edit error by OP, there is a specific check style rule that does not allow if then true else false.

https://rules.sonarsource.com/javascript/rspec-1126/

30

u/halfanothersdozen May 12 '23

Considering that is a javascript rule I would expect it to always fail this build.

-15

u/[deleted] May 12 '23

It’s the same rule in java.

12

u/BertRenolds May 12 '23

Then you should have linked the Java one.

-3

u/BroBroMate May 13 '23

Oh my God, how pedantic can you be.