Credence.RuleName
(credence v0.7.1)
Copy Markdown
The one place that turns a rule's name into every derived form — snake, Pascal, rule atom, rule module, and the conventional paths/modules of its test files.
The naming convention (rule Credence.Pattern.NoFoo lives at
lib/pattern/no_foo.ex; its check test is test/pattern/no_foo_check_test.exs
defining Credence.Pattern.NoFooCheckTest) used to be re-typed in several places
— MetaTestSupport.test_path/2, RuleTestCompletenessTest, and (soon) the
generator and its pin. Re-typing means the copies can drift. Here it is derived
once, and everyone — the generator that writes the files, the gates that
check them, and the pin that proves the generator matches the gates — calls
the same code. There is nothing to drift from.
Summary
Functions
Derive every name form from a rule name ("NoFooBar" or "no_foo_bar") and
its type.
Derive from an existing rule module, inferring the type from its namespace. Used by the gates, which iterate over discovered rule modules.
The conventionally-named test module for a rule's kind file, e.g.
Credence.Pattern.NoFooCheckTest for kind "check".
The conventional path of a rule's kind test file
("test/<type>/<snake>_<kind>_test.exs"). kind is "check", "fix",
"equivalence", "analyze", …
Types
Functions
Derive every name form from a rule name ("NoFooBar" or "no_foo_bar") and
its type.
Derive from an existing rule module, inferring the type from its namespace. Used by the gates, which iterate over discovered rule modules.
The conventionally-named test module for a rule's kind file, e.g.
Credence.Pattern.NoFooCheckTest for kind "check".
The conventional path of a rule's kind test file
("test/<type>/<snake>_<kind>_test.exs"). kind is "check", "fix",
"equivalence", "analyze", …