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

fix: negated_is_nil when nested in guards #1096

Closed
wants to merge 1 commit into from

Conversation

pdm-jd
Copy link

@pdm-jd pdm-jd commented Nov 22, 2023

If a custom guard uses not is_nil(foo), the number of issues reported by Credo.Check.Refactor.NegatedIsNil increases significantly.

For instance, this would report three violations.

defguard custom_guard(value) when not is_nil(value)

def bar(foo, baz) when not is_nil(foo) and custom_guard(baz) do
end

This change ensures only a maximum of one issue per part of the guard will be reported. See the added tests for examples.

If a custom guard uses `not is_nil(foo)`, the number of issues reported
by `Credo.Check.Refactor.NegatedIsNil` increases significantly.

For instance, this would report three violations.

```elixir
defguard custom_guard(value) when not is_nil(value)

def bar(foo, baz) when not is_nil(foo) and custom_guard(baz) do
end
```

This change ensures only a maximum of one issue per part of the guard will
be reported. See the added tests for examples.
@pdm-jd
Copy link
Author

pdm-jd commented Nov 22, 2023

Oof, #1094 beat me too it.

@pdm-jd pdm-jd closed this Nov 22, 2023
@rrrene
Copy link
Owner

rrrene commented Dec 11, 2023

@pdm-jd Still glad you took the time 👍

@pdm-jd pdm-jd deleted the fix/negated_is_nil-recursion branch December 13, 2023 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants