Closed jsolana closed 11 months ago
You can do that by making my_custom_checks
a Credo plugin (which has to be enabled in your config).
That plugin then has to add a default config via Credo.Plugin.register_default_config/2
.
The config you're adding has to add your checks using the :extra
key (the last part is important, see here and scroll down to :extra
).
Again: The plugin has to be enabled via a project config or a global one.
Hi! I tried a different approach in this example
I defined a lib (my_credo) with checks and a .credo.exs
file.
Then in a random project if I want to apply those checks, I can run
mix credo --config-name my-rules --config-file ./deps/my_credo/config/.credo.exs
To avoid this command, I can define aliases to run this easily.
Wdyt?
It is better with the plugin approach? What I want to do is to use this new checks to be executed in CI/CD pipelines too, and the most seamlessly and less manual work to be done integration the best :)
Thanks a lot!!
@jsolana your approach is fine and pragmatic. It might even be more transparent for someone new to a project 👍
Hi mates! I have a question related about if is possible to define an internal .credo.exs in a dependency library with custom checks, eg:
my_credo_checks
, add this dependency to a project, eg:my_project
and when runmix credo
run the default checks + custom checks defined inmy_credo_checks
.The idea is to avoid (if is possible) create a .credo.exs file in every project defining the checks as is described here.
Thanks a lot!!
Environment
Credo version (mix credo -v):
Version 1.7.1
Erlang/Elixir version (elixir -v):
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Elixir 1.14.2 (compiled with Erlang/OTP 23)
Operating system (sw_vers):
ProductName: macOS ProductVersion: 12.5.1 BuildVersion: 21G83
Expected outcome
Have a
my_custom_checks
project with a .credo.exs file with all checks configured as is described here. Add this dependency to a project,my_project
and when runmix credo
run all default checks + custom checks defined inmy_custom_check
.Actual outcome
Running
mix credo
inmy_project
only run default checks. I need to add a .credo.exs config file with the custom checks to run them when runmix credo