Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions REVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 9 additions & 14 deletions src/api/client.rs
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Pre-existing non-top-of-file imports in src/api/client.rs

Lines 52-58 of src/api/client.rs contain use statements placed after the api_error function definition (lines 22-50), rather than grouped with the other imports at lines 1-9. The new REVIEW.md rule states 'Place all use imports at the top of the file or module.' While the PR correctly moves NonZeroU64 to line 2, these other imports remain in their mid-file position. This is a pre-existing pattern that predates this PR and is outside the diff hunks, but it's arguably inconsistent with the rule being introduced here.

(Refers to lines 52-58)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — moved these super:: imports up to the top of the file alongside the other imports. Fixed in the latest commit.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::Debug;
use std::num::NonZeroU64;
use std::time::Duration;

use anyhow::{Context, Result};
Expand All @@ -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
Expand Down Expand Up @@ -48,14 +57,6 @@ fn api_error<E: Debug + Serialize>(e: ProgenitorError<E>) -> 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")))
Expand Down Expand Up @@ -105,8 +106,6 @@ impl ApiClient {
offset: u32,
scan_id: Option<&ListPublicBugsWorkflowRequestId>,
) -> Result<BugsResponse> {
use std::num::NonZeroU64;

self.inner
.list_public_bugs(
NonZeroU64::new(limit.into()),
Expand Down Expand Up @@ -154,8 +153,6 @@ impl ApiClient {
limit: u32,
offset: u32,
) -> Result<ScansResponse> {
use std::num::NonZeroU64;

self.inner
.list_public_scans(NonZeroU64::new(limit.into()), Some(offset.into()), repo_id)
.await
Expand All @@ -164,8 +161,6 @@ impl ApiClient {
}

pub async fn list_repos(&self, limit: u32, offset: u32) -> Result<ReposResponse> {
use std::num::NonZeroU64;

self.inner
.list_public_repos(NonZeroU64::new(limit.into()), Some(offset.into()))
.await
Expand Down
3 changes: 1 addition & 2 deletions src/config/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub fn acquire_update_lock() -> Result<File> {
mod tests {
use std::process;
use std::sync::Mutex;
use std::thread;

use super::*;

Expand Down Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ enum Commands {
#[cfg(test)]
mod tests {
use super::*;
use crate::api::types::BugReviewState;

#[test]
fn silent_when_bugs_list_json() {
Expand Down Expand Up @@ -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, .. },
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Loading