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

[Proposal] Allow to exclude dependency namespaces in Credo.Check.Refactor.ModuleDependencies #106

Open
Eiji7 opened this issue Dec 13, 2024 · 3 comments

Comments

@Eiji7
Copy link

Eiji7 commented Dec 13, 2024

credo prints messages about too many module dependencies that are expected. Unfortunately I'm unable to exclude them (as I can only exclude file path or whole module having many dependencies). I would like to check if except said group my module does not have too much dependencies.

The argument for it is to work with a group of sub-modules (modules in same namespace) instead of single and huge one. In my case there are 8 sub-modules, so I don't need a lot of effort to cause credo's message. I'm working on custom DSL (think about Ecto.Schema) and either I have a huge module with many dependencies or I split it based on features (like each DSL macro).

I think about support for 3rd argument in below code:
https://github.com/rrrene/credo/blob/91502cec785f8a12633851384d6ec83c0c549d39/lib/credo/check/refactor/module_dependencies.ex#L87

and add reject_namespaces/2 like:

  defp reject_namespaces(dependencies, namespaces) do
    Enum.reject(dependencies, &keep?(&1, namespaces))
  end

Current workaround is to put below line at the start of file defining module with many dependencies:

# credo:disable-for-this-file Credo.Check.Refactor.ModuleDependencies

This feature should be simple to implement and I think it would be very helpful. What do you think about it?

@rrrene rrrene transferred this issue from rrrene/credo Dec 14, 2024
@rrrene
Copy link
Owner

rrrene commented Dec 14, 2024

@Eiji7 Hi, I transfered this issue to the proposal repo, as described in Credo's issue template 👍

@rrrene
Copy link
Owner

rrrene commented Dec 15, 2024

I would like to check if except said group my module does not have too much dependencies.

Okay, for my understanding: You have a module - let's call it Foo.API that reaches out in many other modules, but this is by design. Like Ecto.Schema it is sort of a fascade for the other module's functionalities. And now you would like to be able to tell the check: "Tell me if Foo.API is reaching out into too many other modules, but ignore a given list of modules, because it is supposed to reach out into these modules."

Correct?

@Eiji7
Copy link
Author

Eiji7 commented Dec 15, 2024

Yes, to be specific it would be any module starting with Foo.API.

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

No branches or pull requests

2 participants