Skip to content

Conversation

@alexisruccius
Copy link

The ModuleDependencies check was incorrectly triggered on code under the test
folder with default settings.

Example:

mix credo test/supex_test.exs
... 
[F] → Module has too many dependencies: 11 (max is 10)
test/supex_test.exs:1:11 #(SupexTest)

Cause: Path.dirname/1 does not return a trailing /, so first-level test files
(e.g. test/foo_test.exs) were not excluded
(lib/credo/check/refactor/module_dependencies.ex:65).

Fix: Adjusted the default :excluded_paths regex to also match first-level test
files.
Added a test to confirm files in test/ are excluded.

PS: Thanks for this awesome project :)

@rrrene
Copy link
Owner

rrrene commented Nov 11, 2025

Hi, thx for the PR.

I think this now excludes all files in directories starting with test. Is this intended?

@alexisruccius
Copy link
Author

Hi :)

Yes, that’s intentional — the updated regex now matches any path starting with test, ensuring first-level test files like test/foo_test.exs are also excluded.
I understood the default intent to be to exclude all test files, and this change aligns with that.
It still only applies to paths whose dirname begins with test, so non-test directories (e.g. lib/testable/...) remain unaffected.

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