Fix default :excluded_paths regex in ModuleDependencies check to exclude first-level test files
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 :)
Hi, thx for the PR.
I think this now excludes all files in directories starting with test. Is this intended?
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.