Skip to content

Commit cabce09

Browse files
Fix CI failures in PR #566
1 parent c67ae64 commit cabce09

5 files changed

Lines changed: 626 additions & 228 deletions

File tree

‎bots/rhodibot/src/fleet.rs‎

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ fn rule_id(check_name: &str) -> String {
5353
"CONTRIBUTING.md" | "CONTRIBUTING.adoc" => format!("{}-004", RULE_PREFIX),
5454
"CODE_OF_CONDUCT.md" | "CODE_OF_CONDUCT.adoc" => format!("{}-005", RULE_PREFIX),
5555
".claude/CLAUDE.md" => format!("{}-006", RULE_PREFIX),
56-
".machine_readable/STATE.scm" | ".machine_readable/STATE.a2ml" => format!("{}-007", RULE_PREFIX),
57-
".machine_readable/META.scm" | ".machine_readable/META.a2ml" => format!("{}-008", RULE_PREFIX),
58-
".machine_readable/ECOSYSTEM.scm" | ".machine_readable/ECOSYSTEM.a2ml" => format!("{}-009", RULE_PREFIX),
56+
".machine_readable/STATE.scm" | ".machine_readable/STATE.a2ml" => {
57+
format!("{}-007", RULE_PREFIX)
58+
}
59+
".machine_readable/META.scm" | ".machine_readable/META.a2ml" => {
60+
format!("{}-008", RULE_PREFIX)
61+
}
62+
".machine_readable/ECOSYSTEM.scm" | ".machine_readable/ECOSYSTEM.a2ml" => {
63+
format!("{}-009", RULE_PREFIX)
64+
}
5965
".github/workflows" => format!("{}-010", RULE_PREFIX),
6066
".editorconfig" => format!("{}-011", RULE_PREFIX),
6167
".gitattributes" => format!("{}-012", RULE_PREFIX),
@@ -68,7 +74,11 @@ fn rule_id(check_name: &str) -> String {
6874
"no-.bot_directives" => format!("{}-LEGACY-001", RULE_PREFIX),
6975
"license-type" => format!("{}-LIC-001", RULE_PREFIX),
7076
name if name.starts_with("no-") => {
71-
format!("{}-BAN-{}", RULE_PREFIX, name.strip_prefix("no-").unwrap_or(name))
77+
format!(
78+
"{}-BAN-{}",
79+
RULE_PREFIX,
80+
name.strip_prefix("no-").unwrap_or(name)
81+
)
7282
}
7383
_ => format!("{}-CUSTOM", RULE_PREFIX),
7484
}
@@ -125,10 +135,9 @@ fn is_fixable(check_name: &str) -> bool {
125135
// (.gitattributes, .gitignore, .claude/CLAUDE.md and
126136
// .machine_readable/bot_directives), which is how an empty-file PR could
127137
// reach a repository and be merged without anyone reading it.
128-
matches!(check_name,
129-
"LICENSE" | "LICENSE.txt" |
130-
"SECURITY.adoc" | "SECURITY.md" |
131-
".editorconfig"
138+
matches!(
139+
check_name,
140+
"LICENSE" | "LICENSE.txt" | "SECURITY.adoc" | "SECURITY.md" | ".editorconfig"
132141
)
133142
}
134143

@@ -150,14 +159,9 @@ pub fn report_to_findings(report: &ComplianceReport) -> Vec<Finding> {
150159
let rid = rule_id(&check.name);
151160
let category = category_string(check.category);
152161

153-
let mut finding = Finding::new(
154-
BotId::Rhodibot,
155-
&rid,
156-
fleet_severity,
157-
&check.message,
158-
)
159-
.with_rule_name(&check.name)
160-
.with_category(category);
162+
let mut finding = Finding::new(BotId::Rhodibot, &rid, fleet_severity, &check.message)
163+
.with_rule_name(&check.name)
164+
.with_category(category);
161165

162166
// Set file path for file-based checks
163167
if !check.name.starts_with("license-type") && !check.name.starts_with("no-") {
@@ -197,7 +201,10 @@ pub fn publish_to_context(
197201
let data = std::fs::read_to_string(context_path)?;
198202
serde_json::from_str(&data)?
199203
} else {
200-
let mut ctx = Context::new(&repo_full_name, context_path.parent().unwrap_or(Path::new(".")));
204+
let mut ctx = Context::new(
205+
&repo_full_name,
206+
context_path.parent().unwrap_or(Path::new(".")),
207+
);
201208
ctx.register_bot(BotId::Rhodibot);
202209
ctx
203210
};
@@ -208,16 +215,25 @@ pub fn publish_to_context(
208215
// Convert and add findings
209216
let findings = report_to_findings(report);
210217
let findings_count = findings.len();
211-
let errors_count = findings.iter().filter(|f| f.severity == FleetSeverity::Error).count();
218+
let errors_count = findings
219+
.iter()
220+
.filter(|f| f.severity == FleetSeverity::Error)
221+
.count();
212222

213223
context.add_findings(findings);
214224

215225
// Store RSR-specific metadata
216226
context.set_data("rsr:score", serde_json::json!(report.score));
217227
context.set_data("rsr:max_score", serde_json::json!(report.max_score));
218228
context.set_data("rsr:percentage", serde_json::json!(report.percentage));
219-
context.set_data("rsr:policy", serde_json::json!(format!("{}", report.policy)));
220-
context.set_data("rsr:required_passed", serde_json::json!(report.required_passed));
229+
context.set_data(
230+
"rsr:policy",
231+
serde_json::json!(format!("{}", report.policy)),
232+
);
233+
context.set_data(
234+
"rsr:required_passed",
235+
serde_json::json!(report.required_passed),
236+
);
221237

222238
// Complete rhodibot execution
223239
let _ = context.complete_bot(

0 commit comments

Comments
 (0)