Fix formatting and clippy warnings across workspace
- Run cargo fmt on all crates - Fix regex patterns using unsupported lookahead in patterns.rs - Replace unwrap() calls with compile_regex() helper - Fix never type fallback in GitHub tracker - Fix redundant field name in findings page - Allow enum_variant_names for Dioxus Route enum - Fix &mut Vec -> &mut [T] clippy lint in sbom.rs - Mark unused-but-intended APIs with #[allow(dead_code)] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -69,8 +69,9 @@ impl IssueTracker for GitHubTracker {
|
||||
// Use the REST API directly for state update
|
||||
let route = format!("/repos/{owner}/{repo}/issues/{issue_number}");
|
||||
let body = serde_json::json!({ "state": state_str });
|
||||
self.client
|
||||
.post::<serde_json::Value, _>(route, Some(&body))
|
||||
let _: serde_json::Value = self
|
||||
.client
|
||||
.post(route, Some(&body))
|
||||
.await
|
||||
.map_err(|e| CoreError::IssueTracker(format!("GitHub update issue failed: {e}")))?;
|
||||
|
||||
@@ -123,8 +124,9 @@ impl IssueTracker for GitHubTracker {
|
||||
});
|
||||
|
||||
let route = format!("/repos/{owner}/{repo}/pulls/{pr_number}/reviews");
|
||||
self.client
|
||||
.post::<serde_json::Value, ()>(route, Some(&review_body))
|
||||
let _: serde_json::Value = self
|
||||
.client
|
||||
.post(route, Some(&review_body))
|
||||
.await
|
||||
.map_err(|e| CoreError::IssueTracker(format!("GitHub PR review failed: {e}")))?;
|
||||
|
||||
|
||||
@@ -63,11 +63,14 @@ impl IssueTracker for GitLabTracker {
|
||||
if !resp.status().is_success() {
|
||||
let status = resp.status();
|
||||
let body = resp.text().await.unwrap_or_default();
|
||||
return Err(CoreError::IssueTracker(format!("GitLab returned {status}: {body}")));
|
||||
return Err(CoreError::IssueTracker(format!(
|
||||
"GitLab returned {status}: {body}"
|
||||
)));
|
||||
}
|
||||
|
||||
let issue: serde_json::Value = resp.json().await
|
||||
.map_err(|e| CoreError::IssueTracker(format!("Failed to parse GitLab response: {e}")))?;
|
||||
let issue: serde_json::Value = resp.json().await.map_err(|e| {
|
||||
CoreError::IssueTracker(format!("Failed to parse GitLab response: {e}"))
|
||||
})?;
|
||||
|
||||
Ok(TrackerIssue::new(
|
||||
String::new(),
|
||||
@@ -136,7 +139,9 @@ impl IssueTracker for GitLabTracker {
|
||||
let project = Self::project_path(owner, repo);
|
||||
|
||||
// Post overall review as MR note
|
||||
let note_url = self.api_url(&format!("/projects/{project}/merge_requests/{pr_number}/notes"));
|
||||
let note_url = self.api_url(&format!(
|
||||
"/projects/{project}/merge_requests/{pr_number}/notes"
|
||||
));
|
||||
self.http
|
||||
.post(¬e_url)
|
||||
.header("PRIVATE-TOKEN", self.token.expose_secret())
|
||||
@@ -147,7 +152,9 @@ impl IssueTracker for GitLabTracker {
|
||||
|
||||
// Post individual line comments as MR discussions
|
||||
for comment in comments {
|
||||
let disc_url = self.api_url(&format!("/projects/{project}/merge_requests/{pr_number}/discussions"));
|
||||
let disc_url = self.api_url(&format!(
|
||||
"/projects/{project}/merge_requests/{pr_number}/discussions"
|
||||
));
|
||||
let payload = serde_json::json!({
|
||||
"body": comment.body,
|
||||
"position": {
|
||||
|
||||
@@ -12,7 +12,12 @@ pub struct JiraTracker {
|
||||
}
|
||||
|
||||
impl JiraTracker {
|
||||
pub fn new(base_url: String, email: String, api_token: SecretString, project_key: String) -> Self {
|
||||
pub fn new(
|
||||
base_url: String,
|
||||
email: String,
|
||||
api_token: SecretString,
|
||||
project_key: String,
|
||||
) -> Self {
|
||||
Self {
|
||||
base_url: base_url.trim_end_matches('/').to_string(),
|
||||
email,
|
||||
@@ -25,7 +30,10 @@ impl JiraTracker {
|
||||
fn auth_header(&self) -> String {
|
||||
use base64::Engine;
|
||||
let credentials = format!("{}:{}", self.email, self.api_token.expose_secret());
|
||||
format!("Basic {}", base64::engine::general_purpose::STANDARD.encode(credentials))
|
||||
format!(
|
||||
"Basic {}",
|
||||
base64::engine::general_purpose::STANDARD.encode(credentials)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +73,10 @@ impl IssueTracker for JiraTracker {
|
||||
|
||||
if !labels.is_empty() {
|
||||
payload["fields"]["labels"] = serde_json::Value::Array(
|
||||
labels.iter().map(|l| serde_json::Value::String(l.clone())).collect(),
|
||||
labels
|
||||
.iter()
|
||||
.map(|l| serde_json::Value::String(l.clone()))
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,10 +93,14 @@ impl IssueTracker for JiraTracker {
|
||||
if !resp.status().is_success() {
|
||||
let status = resp.status();
|
||||
let body = resp.text().await.unwrap_or_default();
|
||||
return Err(CoreError::IssueTracker(format!("Jira returned {status}: {body}")));
|
||||
return Err(CoreError::IssueTracker(format!(
|
||||
"Jira returned {status}: {body}"
|
||||
)));
|
||||
}
|
||||
|
||||
let issue: serde_json::Value = resp.json().await
|
||||
let issue: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| CoreError::IssueTracker(format!("Failed to parse Jira response: {e}")))?;
|
||||
|
||||
let key = issue["key"].as_str().unwrap_or("").to_string();
|
||||
@@ -108,7 +123,10 @@ impl IssueTracker for JiraTracker {
|
||||
status: &str,
|
||||
) -> Result<(), CoreError> {
|
||||
// Get available transitions
|
||||
let url = format!("{}/rest/api/3/issue/{external_id}/transitions", self.base_url);
|
||||
let url = format!(
|
||||
"{}/rest/api/3/issue/{external_id}/transitions",
|
||||
self.base_url
|
||||
);
|
||||
let resp = self
|
||||
.http
|
||||
.get(&url)
|
||||
@@ -129,11 +147,17 @@ impl IssueTracker for JiraTracker {
|
||||
};
|
||||
|
||||
if let Some(transition) = transitions.iter().find(|t| {
|
||||
t["name"].as_str().map(|n| n.eq_ignore_ascii_case(target)).unwrap_or(false)
|
||||
t["name"]
|
||||
.as_str()
|
||||
.map(|n| n.eq_ignore_ascii_case(target))
|
||||
.unwrap_or(false)
|
||||
}) {
|
||||
let transition_id = transition["id"].as_str().unwrap_or("");
|
||||
let transition_id = transition["id"].as_str().unwrap_or_default();
|
||||
self.http
|
||||
.post(&format!("{}/rest/api/3/issue/{external_id}/transitions", self.base_url))
|
||||
.post(format!(
|
||||
"{}/rest/api/3/issue/{external_id}/transitions",
|
||||
self.base_url
|
||||
))
|
||||
.header("Authorization", self.auth_header())
|
||||
.json(&serde_json::json!({ "transition": { "id": transition_id } }))
|
||||
.send()
|
||||
@@ -216,7 +240,10 @@ impl IssueTracker for JiraTracker {
|
||||
if let Some(issue) = body["issues"].as_array().and_then(|arr| arr.first()) {
|
||||
let key = issue["key"].as_str().unwrap_or("").to_string();
|
||||
let url = format!("{}/browse/{}", self.base_url, key);
|
||||
let title = issue["fields"]["summary"].as_str().unwrap_or("").to_string();
|
||||
let title = issue["fields"]["summary"]
|
||||
.as_str()
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
Ok(Some(TrackerIssue::new(
|
||||
String::new(),
|
||||
TrackerType::Jira,
|
||||
|
||||
Reference in New Issue
Block a user