Pure filename predicates shared by the scoping guards of every check.
Checks must scope themselves inside run/2 against source_file.filename —
the files: param is pruned at Credo's pipeline level, which Credo.Test.Case
bypasses entirely, so a check scoped only by files: passes its whole suite
while doing nothing in production. These predicates are the single shared
implementation for that run/2 guard.
No AST, no Credo types — strings in, boolean out.
Summary
Functions
True when filename matches any of fragments at a path-segment boundary.
True when filename ends with any of suffixes.
True when filename is an Elixir script (.exs) — mix.exs, config, tests.
Functions
True when filename matches any of fragments at a path-segment boundary.
A fragment matches when the path starts with it, ends with it, or contains it
immediately after a /. Naive String.contains?/2 is wrong here and has
already shipped a bug: "lib/latest/helpers.ex" contains the substring
"test/" (inside "la-test/"), so a naive exclusion on "test/" silently
disables a check on a real lib file. Same class: "web/" matches
webhooks/, "mix/tasks/" matches vendor/remix/tasks/.
iex> MikaCredoRules.SourceFilter.matches_fragment?("lib/mix/tasks/deploy.ex", ["mix/tasks/"])
true
iex> MikaCredoRules.SourceFilter.matches_fragment?("lib/vendor/remix/tasks/thing.ex", ["mix/tasks/"])
false
True when filename ends with any of suffixes.
Suffix matching is inherently boundary-safe — use it for whole-file-name
scoping params such as config_files and test_files.
iex> MikaCredoRules.SourceFilter.matches_suffix?("test/worker_test.exs", ["_test.exs"])
true
iex> MikaCredoRules.SourceFilter.matches_suffix?("test/support/factory.ex", ["_test.exs"])
false
True when filename is an Elixir script (.exs) — mix.exs, config, tests.