Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint(validators): refactor len conditions #215

Merged
merged 1 commit into from
Mar 11, 2021

Commits on Mar 11, 2021

  1. lint(validators): refactor len conditions

    In our validation procs, there are conditions like
    ```Nim
    if data.hasKey(key):
      if data[key].kind == JString:
    ```
    where the condition being `true` represents the "happy path".
    
    To improve readability, let's try to do this consistently for every
    condition apart from the innermost one; it's easier to see the "happy
    path" when it minimises the number of `else`.
    
    This commit refactors the `len` conditions accordingly, so that we
    prefer `len > 0` and use `len == 0` only when there is no `else`.
    
    This commit also changes a `var` to a `let` to better convey that we
    don't mutate.
    ee7 committed Mar 11, 2021
    Configuration menu
    Copy the full SHA
    910feca View commit details
    Browse the repository at this point in the history