1use alint_core::RuleRegistry;
7
8pub mod case;
9pub mod command;
10pub mod dir_absent;
11pub mod dir_contains;
12pub mod dir_exists;
13pub mod dir_only_contains;
14pub mod every_matching_has;
15pub mod executable_bit;
16pub mod executable_has_shebang;
17pub mod file_absent;
18pub mod file_content_forbidden;
19pub mod file_content_matches;
20pub mod file_ends_with;
21pub mod file_exists;
22pub mod file_footer;
23pub mod file_hash;
24pub mod file_header;
25pub mod file_is_ascii;
26pub mod file_is_text;
27pub mod file_max_lines;
28pub mod file_max_size;
29pub mod file_min_lines;
30pub mod file_min_size;
31pub mod file_shebang;
32pub mod file_starts_with;
33pub mod filename_case;
34pub mod filename_regex;
35pub mod final_newline;
36pub mod fixers;
37pub mod for_each_dir;
38pub mod for_each_file;
39pub mod git_commit_message;
40pub mod git_no_denied_paths;
41pub mod indent_style;
42pub mod io;
43pub mod json_schema_passes;
44pub mod line_endings;
45pub mod line_max_width;
46pub mod max_consecutive_blank_lines;
47pub mod max_directory_depth;
48pub mod max_files_per_directory;
49pub mod no_bidi_controls;
50pub mod no_bom;
51pub mod no_case_conflicts;
52pub mod no_empty_files;
53pub mod no_illegal_windows_names;
54pub mod no_merge_conflict_markers;
55pub mod no_submodules;
56pub mod no_symlinks;
57pub mod no_trailing_whitespace;
58pub mod no_zero_width_chars;
59pub mod pair;
60pub mod shebang_has_executable;
61pub mod structured_path;
62pub mod unique_by;
63
64pub fn register_builtin(registry: &mut RuleRegistry) {
73 registry.register("file_exists", file_exists::build);
74 registry.register("file_absent", file_absent::build);
75 registry.register("dir_exists", dir_exists::build);
76 registry.register("dir_absent", dir_absent::build);
77
78 registry.register("file_content_matches", file_content_matches::build);
79 registry.register("content_matches", file_content_matches::build);
80 registry.register("file_content_forbidden", file_content_forbidden::build);
81 registry.register("content_forbidden", file_content_forbidden::build);
82 registry.register("file_header", file_header::build);
83 registry.register("header", file_header::build);
84 registry.register("file_max_size", file_max_size::build);
85 registry.register("max_size", file_max_size::build);
86 registry.register("file_min_size", file_min_size::build);
87 registry.register("min_size", file_min_size::build);
88 registry.register("file_min_lines", file_min_lines::build);
89 registry.register("min_lines", file_min_lines::build);
90 registry.register("file_max_lines", file_max_lines::build);
91 registry.register("max_lines", file_max_lines::build);
92 registry.register("file_footer", file_footer::build);
93 registry.register("footer", file_footer::build);
94 registry.register("file_shebang", file_shebang::build);
95 registry.register("shebang", file_shebang::build);
96
97 registry.register("json_path_equals", structured_path::json_path_equals_build);
100 registry.register(
101 "json_path_matches",
102 structured_path::json_path_matches_build,
103 );
104 registry.register("yaml_path_equals", structured_path::yaml_path_equals_build);
105 registry.register(
106 "yaml_path_matches",
107 structured_path::yaml_path_matches_build,
108 );
109 registry.register("toml_path_equals", structured_path::toml_path_equals_build);
110 registry.register(
111 "toml_path_matches",
112 structured_path::toml_path_matches_build,
113 );
114 registry.register("json_schema_passes", json_schema_passes::build);
115 registry.register("git_no_denied_paths", git_no_denied_paths::build);
116 registry.register("git_commit_message", git_commit_message::build);
117 registry.register("file_is_text", file_is_text::build);
118 registry.register("is_text", file_is_text::build);
119
120 registry.register("filename_case", filename_case::build);
121 registry.register("filename_regex", filename_regex::build);
122 registry.register("pair", pair::build);
123 registry.register("for_each_dir", for_each_dir::build);
124 registry.register("for_each_file", for_each_file::build);
125 registry.register("dir_only_contains", dir_only_contains::build);
126 registry.register("unique_by", unique_by::build);
127 registry.register("dir_contains", dir_contains::build);
128 registry.register("every_matching_has", every_matching_has::build);
129
130 registry.register("no_trailing_whitespace", no_trailing_whitespace::build);
132 registry.register("final_newline", final_newline::build);
133 registry.register("line_endings", line_endings::build);
134 registry.register("line_max_width", line_max_width::build);
135
136 registry.register(
138 "no_merge_conflict_markers",
139 no_merge_conflict_markers::build,
140 );
141 registry.register("no_bidi_controls", no_bidi_controls::build);
142 registry.register("no_zero_width_chars", no_zero_width_chars::build);
143
144 registry.register("file_is_ascii", file_is_ascii::build);
146 registry.register("no_bom", no_bom::build);
147 registry.register("file_hash", file_hash::build);
148
149 registry.register("max_directory_depth", max_directory_depth::build);
151 registry.register("max_files_per_directory", max_files_per_directory::build);
152 registry.register("no_empty_files", no_empty_files::build);
153
154 registry.register("no_case_conflicts", no_case_conflicts::build);
156 registry.register("no_illegal_windows_names", no_illegal_windows_names::build);
157
158 registry.register("no_symlinks", no_symlinks::build);
160 registry.register("executable_bit", executable_bit::build);
161 registry.register("executable_has_shebang", executable_has_shebang::build);
162 registry.register("shebang_has_executable", shebang_has_executable::build);
163 registry.register("no_submodules", no_submodules::build);
164
165 registry.register("indent_style", indent_style::build);
167 registry.register(
168 "max_consecutive_blank_lines",
169 max_consecutive_blank_lines::build,
170 );
171 registry.register("file_starts_with", file_starts_with::build);
172 registry.register("file_ends_with", file_ends_with::build);
173
174 registry.register("command", command::build);
178}
179
180pub fn builtin_registry() -> RuleRegistry {
183 let mut r = RuleRegistry::new();
184 register_builtin(&mut r);
185 r
186}
187
188#[cfg(test)]
189mod registry_tests {
190 use super::*;
191
192 #[test]
193 fn every_documented_kind_is_registered() {
194 let r = builtin_registry();
195 let known: Vec<&str> = r.known_kinds().collect();
196 for kind in [
197 "file_exists",
199 "file_absent",
200 "dir_exists",
201 "dir_absent",
202 "file_content_matches",
204 "content_matches",
205 "file_content_forbidden",
206 "content_forbidden",
207 "file_header",
208 "header",
209 "file_max_size",
210 "max_size",
211 "file_min_size",
212 "min_size",
213 "file_min_lines",
214 "min_lines",
215 "file_max_lines",
216 "max_lines",
217 "file_footer",
218 "footer",
219 "file_shebang",
220 "shebang",
221 "json_path_equals",
223 "json_path_matches",
224 "yaml_path_equals",
225 "yaml_path_matches",
226 "toml_path_equals",
227 "toml_path_matches",
228 "json_schema_passes",
229 "git_no_denied_paths",
230 "git_commit_message",
231 "file_is_text",
232 "is_text",
233 "filename_case",
235 "filename_regex",
236 "pair",
237 "for_each_dir",
238 "for_each_file",
239 "dir_only_contains",
240 "unique_by",
241 "dir_contains",
242 "every_matching_has",
243 "no_trailing_whitespace",
245 "final_newline",
246 "line_endings",
247 "line_max_width",
248 "no_merge_conflict_markers",
250 "no_bidi_controls",
251 "no_zero_width_chars",
252 "file_is_ascii",
254 "no_bom",
255 "file_hash",
256 "max_directory_depth",
258 "max_files_per_directory",
259 "no_empty_files",
260 "no_case_conflicts",
262 "no_illegal_windows_names",
263 "no_symlinks",
265 "executable_bit",
266 "executable_has_shebang",
267 "shebang_has_executable",
268 "no_submodules",
269 "indent_style",
271 "max_consecutive_blank_lines",
272 "file_starts_with",
273 "file_ends_with",
274 "command",
276 ] {
277 assert!(
278 known.contains(&kind),
279 "{kind} missing from builtin registry"
280 );
281 }
282 }
283}