Skip to main content

drep/languages/definitions/
elixir.rs

1//! Elixir: Credo over `.ex` and `.exs`.
2
3use crate::languages::spec::{
4    DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
5};
6
7/// Elixir deterministic checker.
8///
9/// `mix credo` runs from the project root where `mix.exs` lives; `.credo.exs`
10/// is the config marker, present when the project has tuned (or even merely
11/// accepted) Credo's checks.
12pub static CREDO: ToolSpec = ToolSpec {
13    name: "credo",
14    command: &["mix", "credo", "--format", "json"],
15    local_paths: &[],
16    config_files: &[".credo.exs"],
17    config_flag: None,
18    output_format: OutputFormat::Credo,
19    diagnostics_stream: DiagnosticsStream::Stdout,
20    timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
21    timeout_context: None,
22    establishes_compilation: false,
23    serial_in_repository: false,
24    accepts_files: true,
25};
26
27/// Elixir language entry.
28///
29/// `deps` is deliberately absent from `vendored_dirs` for the reason the JVM
30/// family leaves out `out`: `files::is_ignored_dir` consults the union across
31/// every language, so an entry here would skip `deps/` in repositories with
32/// no Elixir in them at all - and a checked-in `deps/` of real source is a
33/// convention in other ecosystems. Mix projects gitignore `/deps` in
34/// practice, which the walker already honors on its own.
35pub static ELIXIR: LanguageSupport = LanguageSupport {
36    name: "elixir",
37    display_name: "Elixir",
38    extensions: &[".ex", ".exs"],
39    filenames: &[],
40    filename_prefixes: &[],
41    tools: &[&CREDO],
42    conventions: &[
43        "Pattern matches with no fallback clause, crashing on unexpected shapes",
44        "Non-tail recursion over unbounded lists",
45        "Atoms built from untrusted input",
46        "GenServer calls that deadlock against themselves",
47        "Unhandled messages accumulating in a mailbox",
48    ],
49    vendored_dirs: &["_build"],
50};
51
52/// The family's entries in registration order. See `ALL_LANGUAGES`.
53pub(crate) static FAMILY: &[&LanguageSupport] = &[&ELIXIR];