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