diff --git a/REVIEW.md b/REVIEW.md index d66f157..1af6685 100644 --- a/REVIEW.md +++ b/REVIEW.md @@ -5,6 +5,8 @@ Conventions that require human judgment during review. Lint-enforced rules ## Conventions +- Place all `use` imports at the top of the file or module — never inside function + bodies. For test modules, place imports at the top of the `mod tests` block. - Do not use `pub(super)`. Use `pub(crate)` or `pub` instead. - Prefer the narrowest visibility that compiles — plain `fn` over `pub(crate)` when the function is only used within its own module. diff --git a/src/api/client.rs b/src/api/client.rs index ac4d4c8..af9e745 100644 --- a/src/api/client.rs +++ b/src/api/client.rs @@ -1,4 +1,5 @@ use std::fmt::Debug; +use std::num::NonZeroU64; use std::time::Duration; use anyhow::{Context, Result}; @@ -7,6 +8,14 @@ use serde::{Deserialize, Serialize}; use progenitor::progenitor_client::{Error as ProgenitorError, ResponseValue}; +use super::generated::types::CreateRuleBody; +use super::types::{ + Bug, BugDismissalReason, BugId, BugReview, BugReviewState, BugsResponse, + CreatePublicBugReviewBody, CreateRuleInput, CreateRuleResponse, + ListPublicBugsWorkflowRequestId, RepoId, ReposResponse, Rule, RuleCreationRequestId, RuleId, + RuleRequestStatus, RuleRequestsResponse, RulesResponse, ScansResponse, UserInfo, +}; + /// Convert a progenitor client error into a concise anyhow error. /// /// progenitor's own `Display` for `ErrorResponse` dumps headers and the typed @@ -48,14 +57,6 @@ fn api_error(e: ProgenitorError) -> anyhow::Error { anyhow::anyhow!("API error: {e}") } -use super::generated::types::CreateRuleBody; -use super::types::{ - Bug, BugDismissalReason, BugId, BugReview, BugReviewState, BugsResponse, - CreatePublicBugReviewBody, CreateRuleInput, CreateRuleResponse, - ListPublicBugsWorkflowRequestId, RepoId, ReposResponse, Rule, RuleCreationRequestId, RuleId, - RuleRequestStatus, RuleRequestsResponse, RulesResponse, ScansResponse, UserInfo, -}; - fn base_http_client() -> reqwest::ClientBuilder { reqwest::Client::builder() .user_agent(format!("detail-cli/{}", env!("CARGO_PKG_VERSION"))) @@ -105,8 +106,6 @@ impl ApiClient { offset: u32, scan_id: Option<&ListPublicBugsWorkflowRequestId>, ) -> Result { - use std::num::NonZeroU64; - self.inner .list_public_bugs( NonZeroU64::new(limit.into()), @@ -154,8 +153,6 @@ impl ApiClient { limit: u32, offset: u32, ) -> Result { - use std::num::NonZeroU64; - self.inner .list_public_scans(NonZeroU64::new(limit.into()), Some(offset.into()), repo_id) .await @@ -164,8 +161,6 @@ impl ApiClient { } pub async fn list_repos(&self, limit: u32, offset: u32) -> Result { - use std::num::NonZeroU64; - self.inner .list_public_repos(NonZeroU64::new(limit.into()), Some(offset.into())) .await diff --git a/src/config/storage.rs b/src/config/storage.rs index 2c90b96..4f97899 100644 --- a/src/config/storage.rs +++ b/src/config/storage.rs @@ -172,6 +172,7 @@ pub fn acquire_update_lock() -> Result { mod tests { use std::process; use std::sync::Mutex; + use std::thread; use super::*; @@ -461,8 +462,6 @@ api_token = \"old_token\" #[test] fn concurrent_update_config_does_not_corrupt() { - use std::thread; - with_temp_config(|| { // Initialize config update_config(|_| {}).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 2de0234..4d9daa6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -223,6 +223,7 @@ enum Commands { #[cfg(test)] mod tests { use super::*; + use crate::api::types::BugReviewState; #[test] fn silent_when_bugs_list_json() { @@ -460,7 +461,6 @@ mod tests { #[test] fn bugs_list_status_default_is_pending() { - use crate::api::types::BugReviewState; let cli = Cli::try_parse_from(["detail", "bugs", "list", "owner/repo"]).unwrap(); if let Commands::Bugs { command: commands::bugs::BugCommands::List { status, .. }, @@ -475,7 +475,6 @@ mod tests { #[test] fn bugs_list_status_comma_separated_parses() { - use crate::api::types::BugReviewState; let cli = Cli::try_parse_from([ "detail", "bugs", @@ -499,7 +498,6 @@ mod tests { #[test] fn bugs_list_status_repeated_flag_parses() { - use crate::api::types::BugReviewState; let cli = Cli::try_parse_from([ "detail", "bugs",