question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE]: avoid double negation by introducing `enabled:` for modules

See original GitHub issue

Feature Request

Deprecate disabled: module option and introduce enabled.

Alternatively, encourage using enabled and still allow disabled in the cases where it makes the code more readable.

Background / Motivation

Starting out positive, both the positive and the negative case are easy to understand:

  • enabled: ${environment.name != "local"} (read: enabled if environment is not local)
  • enabled: ${environment.name == "local"} (read: enabled if environment is local)

While starting out negative, the negative case can be harder to read:

  • disabled: ${environment.name != "local"} (read: disabled if environment is not local)

Examples with simple boolean algebra:

Easy to understand:

  • enabled: ${environment.name == "kubernetes" || environment.name == "local-kubernetes"} (read: the module is enabled if the environment is kubernetes or local-kubernetes)
  • enabled: ${environment.name != "kubernetes" && environment.name != "local-kubernetes"} (read: the module is enabled if the environment is not kubernetes and not local-kubernetes)
  • disabled: ${environment.name == "kubernetes" || environment.name == "local-kubernetes"} (read: the module is disabled, if environment is kubernetes or local-kubernetes)

Hard to understand

  • disabled: ${environment.name != "kubernetes" && environment.name != "local-kubernetes"} (read: the module is disabled, if environment is not kubernetes and is not local-kubernetes)

So, to sum it up, enabled is okay to understand in all cases, and disabled is hard to understand in case of double negation (at least for me, but also to other people).

What should the user be able to do?

use enabled: to configure wether a module is active, instead of disabled.

Why do they want to do this? What problem does it solve?

Readability

Suggested Implementation(s)

There are 2 options:

  • We can have both enabled and disabled side by side
  • We can deprecate disabled

How important is this feature for you/your team?

🌹 It’s a nice to have, but nice things are nice 🙂

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Orzeliuscommented, Dec 1, 2022

I think most of this would be solved by just naming the complicated expression with a variable

variables:
  isKubernetes: ${environment.name == "kubernetes" || environment.name == "local-kubernetes"}
disabled: ${!var.isKuberetes}
1reaction
stefreakcommented, Nov 30, 2022

I’m okay with keeping both, good point!

@vvagaytsev @Orzelius I would just create a pull request towards 0.13 once all the tests pass? What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[FEATURE]: avoid double negation by introducing `enabled:` for ...
use enabled: to configure wether a module is active, instead of disabled . Why do they want to do this? What problem does...
Read more >
Avoid double negation, unless... - Adam Sawicki
If something has always been enabled in previous versions and you want to give users a possibility to disable it in the new...
Read more >
All C++20 core language features with examples
All C++20 core language features with examples · Introduction · Table of contents · Concepts · Modules · Coroutines · Three-way comparison ·...
Read more >
openresty/lua-nginx-module: Embed the Power of ... - GitHub
NGX_LUA_USE_ASSERT When defined, will enable assertions in the ngx_lua C code base. Recommended for debugging or testing builds. It can introduce some (small) ......
Read more >
2. Building and Running Modules - Linux Device Drivers, 3rd ...
This chapter introduces all the essential concepts about modules and kernel ... resources or avoids clean up altogether, the exit function of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found