rrrene / credo-proposals

Proposals for Credo, the Elixir code analysis tool with a focus on code consistency and teaching
MIT License
9 stars 0 forks source link

Feature: Sharing Credo Configs #56

Open asummers opened 4 years ago

asummers commented 4 years ago

What do you want Credo to do?

I have a lot of projects and I want to share an individual .credo.exs configs between the projects.

How I might imagine this working is in .credo.exs being able to point to a remote file. One difficulty I also see here is if the .credo.exs file contains custom checks, so I'm not sure how this might work and was looking for guidance there, as well as how one might expect this to look in a .credo.exs.

I'm imagining a syntax similar to:

%{
  configs: [
    %{
      remote_path: "https://..."
    }
  ]
}
rrrene commented 4 years ago

I am in favor of this proposal. There is already the --config-file CLI switch and as long as we adhere to its semantics (the given config file is the only config file loaded, skipping transitive loading of config files)

We could (a) add a complimentary config value config_file and (b) make that switch handle HTTP requests as well. :+1:

asummers commented 4 years ago

Do you imagine for custom checks that they would also point to remote files?

rrrene commented 4 years ago

I don't think we should allow custom checks to be referenced remotely. The config is just plain data, which can be parsed safely, but checks would have to be downloaded and executed (by definition).

I am not sure downloading, compiling and executing Elixir code at runtime is the best way to handle this (unless I misunderstand the intent of the proposed feature). Custom checks that are supposed to be available to several projects should probably be wrapped in a Credo plugin.

PragTob commented 1 month ago

:wave:

I'm extremely interested in this as well. I'm not sure if a remote URL is the best solution though (but it would work).

For the problem with custom checks, my proposal would be to make it work via creating a valid package (no matter if you put it on hex or fetch it from git) - that package could/would come with all the custom checks you have and all the dependencies to eventual other packages providing custom checks.

Then in .credo.exs you could just have a key like import_config: which loads that configuration - kind of like credos default configuration, and then you can still customize and adjust it in the other parts of the config.

That way we also outsource any authenticating and fetching of the data to fetching packages, meaning credo doesn't have to deal with it.

Would this be something that would be welcome in credo?

I see this as both a solution for OSS (benchee) as well as at various places I've worked.

edit: As always, thanks for all your hard work! :green_heart:

edit2: I understand that --config-file would work with this/kind of like this but I specifically want an ability to override configurations in the .credo.exs itself as sometimes repos are different/have different needs