Skip to content

Commit e7a2dd5

Browse files
committed
fix: unknown url and add groups to categories
1 parent 60fd54e commit e7a2dd5

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

crates/pgls_diagnostics_categories/src/categories.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,11 @@ define_categories! {
9393
"lint/performance",
9494
"lint/safety",
9595
// Lint groups end
96-
}
9796

97+
// Splinter groups start
98+
"splinter",
99+
"splinter/performance",
100+
"splinter/security",
101+
"splinter/unknown",
102+
// Splinter groups end
103+
}

xtask/codegen/src/generate_splinter.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn update_categories_file(rules: BTreeMap<String, RuleInfo>) -> Result<()> {
152152
let categories_path =
153153
project_root().join("crates/pgls_diagnostics_categories/src/categories.rs");
154154

155-
let content = fs2::read_to_string(&categories_path)?;
155+
let mut content = fs2::read_to_string(&categories_path)?;
156156

157157
// Generate splinter rule entries grouped by category
158158
let mut splinter_rules: Vec<(String, String)> = rules
@@ -187,14 +187,39 @@ fn update_categories_file(rules: BTreeMap<String, RuleInfo>) -> Result<()> {
187187
let rules_start = "// splinter rules start";
188188
let rules_end = "// splinter rules end";
189189

190-
let new_content = replace_between_markers(
190+
content = replace_between_markers(
191191
&content,
192192
rules_start,
193193
rules_end,
194194
&format!("\n{splinter_entries}\n "),
195195
)?;
196196

197-
fs2::write(categories_path, new_content)?;
197+
// Generate splinter group entries
198+
let mut groups: Vec<String> = splinter_rules
199+
.iter()
200+
.map(|(group, _)| group.clone())
201+
.collect();
202+
groups.sort();
203+
groups.dedup();
204+
205+
let mut group_entries = vec![" \"splinter\",".to_string()];
206+
for group in groups {
207+
group_entries.push(format!(" \"splinter/{}\",", group));
208+
}
209+
let groups_content = group_entries.join("\n");
210+
211+
// Replace content between splinter groups markers
212+
let groups_start = "// Splinter groups start";
213+
let groups_end = "// Splinter groups end";
214+
215+
content = replace_between_markers(
216+
&content,
217+
groups_start,
218+
groups_end,
219+
&format!("\n{groups_content}\n "),
220+
)?;
221+
222+
fs2::write(categories_path, content)?;
198223

199224
Ok(())
200225
}

0 commit comments

Comments
 (0)