Skip to main content

drep/languages/definitions/
mod.rs

1//! The registered languages, split by ecosystem.
2//!
3//! Adding a language is an entry in its ecosystem file (plus a new file for
4//! a new ecosystem) and, if it has one, a tool output parser. No control flow
5//! anywhere else in drep changes.
6//!
7//! `config_files` is what makes a tool run at all: drep checks a project against
8//! the style that project has *chosen*, so a repo with no eslint config gets no
9//! eslint findings rather than a wall of default-preset complaints.
10//!
11//! Every ecosystem's statics are re-exported from here so the module path a
12//! consumer uses (`definitions::RUFF`) is unchanged by the split.
13
14mod c_family;
15mod docker;
16mod elixir;
17mod go;
18mod javascript;
19mod jvm;
20mod php;
21mod python;
22mod ruby;
23mod rust;
24mod shell;
25mod sql;
26mod swift;
27mod terraform;
28
29pub use c_family::{C, CPP, CPPCHECK, CSHARP, DOTNET_FORMAT};
30pub use docker::{DOCKER, HADOLINT};
31pub use elixir::{CREDO, ELIXIR};
32pub use go::{GO, GO_VET, GOFMT};
33pub use javascript::{ESLINT, JAVASCRIPT, SVELTE, TSC, TYPESCRIPT, VUE};
34pub use jvm::{CHECKSTYLE, GROOVY, JAVA, KOTLIN, KTLINT, SCALA};
35pub use php::{PHP, PHPCS};
36pub use python::{PYTHON, RUFF};
37pub use ruby::{RUBOCOP, RUBY};
38pub use rust::{CLIPPY, RUST_LANG};
39pub use shell::{SHELL, SHELLCHECK};
40pub use sql::{SQL, SQLFLUFF};
41pub use swift::{SWIFT, SWIFTLINT};
42pub use terraform::{TERRAFORM, TFLINT};
43
44use super::spec::LanguageSupport;
45use std::sync::LazyLock;
46
47/// Every registered language, in registration order.
48///
49/// Assembled from each ecosystem file's own `FAMILY` slice rather than
50/// maintained here as a hand-written list. A static can be defined and
51/// re-exported above while never being registered, and no test could see the
52/// omission - the same failure class as a test file no `mod` declares. With
53/// the list built beside the definitions, leaving a language out means
54/// leaving it out of the file that defines it.
55///
56/// The order is the order `doctor` reports languages in, so it remains part
57/// of the output contract - but the contract is now two-level: families in
58/// the order listed below, and within a family the order its own file writes.
59/// Appending a language to its family therefore moves nothing, while adding a
60/// family appends only at the position it is listed here. Assembling this way
61/// reordered the flat list once, on the commit that introduced it, by moving
62/// Vue and Svelte up beside TypeScript where they belong; the previous rule
63/// ("append rather than insert") described the hand-written list and would now
64/// forbid the grouping that replaced it.
65///
66/// `all_languages_returns_every_registered_language` pins the resulting
67/// sequence in full, so a reorder is a visible test change rather than a
68/// silent one.
69pub(crate) static ALL_LANGUAGES: LazyLock<Vec<&'static LanguageSupport>> = LazyLock::new(|| {
70    [
71        python::FAMILY,
72        javascript::FAMILY,
73        go::FAMILY,
74        rust::FAMILY,
75        jvm::FAMILY,
76        shell::FAMILY,
77        swift::FAMILY,
78        c_family::FAMILY,
79        ruby::FAMILY,
80        php::FAMILY,
81        terraform::FAMILY,
82        elixir::FAMILY,
83        sql::FAMILY,
84        docker::FAMILY,
85    ]
86    .concat()
87});