• xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    11
    arrow-down
    2
    ·
    10 months ago

    If you’re in a language that supports it, please don’t use if (false) use if ($disallowAllUsers = false && $whateverTheRealConditionIs)

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        10 months ago

        That specific language is PHP, but the tip is applicable in any language that supports inline assignment.

        • The Octonaut
          link
          fedilink
          arrow-up
          6
          ·
          10 months ago
          if (true === $wantToCauseErrorsForFun) {
              badOldFunction();
          } 
          
    • Kogasa@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      10 months ago

      The assignment syntax is too close to comparison, which is what is more typical in that position. I would recommend

      const bool _isFeatureEnabled = false;
      if (_isFeatureEnabled && ...)
      

      if not a proper feature flag (or just remove the code).