Menu

Suggestion for silly boolean check

2024-05-31
2024-05-31
  • Steve Albright

    Steve Albright - 2024-05-31

    I see many instances of useless checks like

    if(true == someFunctionThatReturnsABoolean()) vs if(someFunctionThatReturnsABoolean())

    Or google test

    EXPECT_EQ(TRUE, someValue) vs EXPECT_TRUE(someValue)

    same for false.

    Maybe a check to encourage people to keep it simple...

     
  • CHR

    CHR - 2024-05-31

    clang-tidy has a readability-simplify-boolean-expr check.

     
    • Steve Albright

      Steve Albright - 2024-05-31

      Thanks, we currently aren't using that tool but I'll look into it.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.