Skip to content

Support enabling check via {Credo.Check.*, true}#1281

Open
s3cur3 wants to merge 1 commit into
rrrene:masterfrom
s3cur3:ty/support-enable-true
Open

Support enabling check via {Credo.Check.*, true}#1281
s3cur3 wants to merge 1 commit into
rrrene:masterfrom
s3cur3:ty/support-enable-true

Conversation

@s3cur3

@s3cur3 s3cur3 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

A common mistake I see a lot is folks (including myself) thinking you can modify a disabled check line in the config like:

{Credo.Check.Readability.ModuleDoc, false},

...by simply changing the true to false. If you do this on mainline Credo, it will crash with a fairly cryptic error (you can't tell from the stacktrace which check caused the problem):

** (Protocol.UndefinedError) protocol Enumerable not implemented for Atom

Got value:

    true

    (elixir 1.19.4) lib/enum.ex:5: Enumerable.impl_for!/1
    (elixir 1.19.4) lib/enum.ex:170: Enumerable.reduce/3
    (elixir 1.19.4) lib/enum.ex:4570: Enum.each/2
    (elixir 1.19.4) lib/enum.ex:961: Enum."-each/2-lists^foreach/1-0-"/2
    (credo 1.8.0-dev) lib/credo/execution/task/validate_config.ex:75: Credo.Execution.Task.ValidateConfig.validate_checks/1
    (credo 1.8.0-dev) lib/credo/execution/task/validate_config.ex:12: Credo.Execution.Task.ValidateConfig.call/2
    (credo 1.8.0-dev) lib/credo/execution/task.ex:132: Credo.Execution.Task.do_run/3
    (elixir 1.19.4) lib/enum.ex:2520: Enum."-reduce/3-lists^foldl/2-0-"/3

With this change, the inferred behavior ("I should be able to change false to true to enable it") will now "just work."

A common mistake I see a lot is folks (including myself) thinking you can modify this disabled check line in the config:

```elixir
{Credo.Check.Readability.ModuleDoc, false},
```

...by simply changing the `true` to `false`. If you do this on mainline Credo, it will crash when trying to operate on `{check_name, true}` with a fairly cryptic error:

```
** (Protocol.UndefinedError) protocol Enumerable not implemented for Atom

Got value:

    true

    (elixir 1.19.4) lib/enum.ex:5: Enumerable.impl_for!/1
    (elixir 1.19.4) lib/enum.ex:170: Enumerable.reduce/3
    (elixir 1.19.4) lib/enum.ex:4570: Enum.each/2
    (elixir 1.19.4) lib/enum.ex:961: Enum."-each/2-lists^foreach/1-0-"/2
    (credo 1.8.0-dev) lib/credo/execution/task/validate_config.ex:75: Credo.Execution.Task.ValidateConfig.validate_checks/1
    (credo 1.8.0-dev) lib/credo/execution/task/validate_config.ex:12: Credo.Execution.Task.ValidateConfig.call/2
    (credo 1.8.0-dev) lib/credo/execution/task.ex:132: Credo.Execution.Task.do_run/3
    (elixir 1.19.4) lib/enum.ex:2520: Enum."-reduce/3-lists^foldl/2-0-"/3
```

With this change, the inferred behavior ("I should be able to change false to true to enable it") will now "just work."
rrrene added a commit that referenced this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant