refactor: Remove redundant doc comments throughout codebase

Removes module-level doc comments (//! lines) and excessive inline doc
comments that were duplicating information already evident from:
- Function/struct names (self-documenting code)
- Type signatures (the what is clear from types)
- Implementation context (the how is clear from code)

Affected modules:
- cli/* - Removed command descriptions duplicating clap help text
- core/* - Removed module headers and obvious function docs
- documents/* - Removed extractor/regenerator/truncation docs
- embedding/* - Removed pipeline and chunking docs
- gitlab/* - Removed client and transformer docs (kept type definitions)
- ingestion/* - Removed orchestrator and ingestion docs
- search/* - Removed FTS and vector search docs

Philosophy: Code should be self-documenting. Comments should explain
"why" (business decisions, non-obvious constraints) not "what" (which
the code itself shows). This change reduces noise and maintenance burden
while keeping the codebase just as understandable.

Retains comments for:
- Non-obvious business logic
- Important safety invariants
- Complex algorithm explanations
- Public API boundaries where generated docs matter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-02-05 00:04:32 -05:00
parent 976ad92ef0
commit 65583ed5d6
57 changed files with 143 additions and 1693 deletions

View File

@@ -1,5 +1,3 @@
//! Show command - display detailed entity information from local database.
use console::style;
use rusqlite::Connection;
use serde::Serialize;
@@ -11,7 +9,6 @@ use crate::core::paths::get_db_path;
use crate::core::project::resolve_project;
use crate::core::time::ms_to_iso;
/// Merge request metadata for display.
#[derive(Debug, Serialize)]
pub struct MrDetail {
pub id: i64,
@@ -35,14 +32,12 @@ pub struct MrDetail {
pub discussions: Vec<MrDiscussionDetail>,
}
/// MR discussion detail for display.
#[derive(Debug, Serialize)]
pub struct MrDiscussionDetail {
pub notes: Vec<MrNoteDetail>,
pub individual_note: bool,
}
/// MR note detail for display (includes DiffNote position).
#[derive(Debug, Serialize)]
pub struct MrNoteDetail {
pub author_username: String,
@@ -52,7 +47,6 @@ pub struct MrNoteDetail {
pub position: Option<DiffNotePosition>,
}
/// DiffNote position context for display.
#[derive(Debug, Clone, Serialize)]
pub struct DiffNotePosition {
pub old_path: Option<String>,
@@ -62,7 +56,6 @@ pub struct DiffNotePosition {
pub position_type: Option<String>,
}
/// Issue metadata for display.
#[derive(Debug, Serialize)]
pub struct IssueDetail {
pub id: i64,
@@ -79,14 +72,12 @@ pub struct IssueDetail {
pub discussions: Vec<DiscussionDetail>,
}
/// Discussion detail for display.
#[derive(Debug, Serialize)]
pub struct DiscussionDetail {
pub notes: Vec<NoteDetail>,
pub individual_note: bool,
}
/// Note detail for display.
#[derive(Debug, Serialize)]
pub struct NoteDetail {
pub author_username: String,
@@ -95,7 +86,6 @@ pub struct NoteDetail {
pub is_system: bool,
}
/// Run the show issue command.
pub fn run_show_issue(
config: &Config,
iid: i64,
@@ -104,13 +94,10 @@ pub fn run_show_issue(
let db_path = get_db_path(config.storage.db_path.as_deref());
let conn = create_connection(&db_path)?;
// Find the issue
let issue = find_issue(&conn, iid, project_filter)?;
// Load labels
let labels = get_issue_labels(&conn, issue.id)?;
// Load discussions with notes
let discussions = get_issue_discussions(&conn, issue.id)?;
Ok(IssueDetail {
@@ -129,7 +116,6 @@ pub fn run_show_issue(
})
}
/// Internal issue row from query.
struct IssueRow {
id: i64,
iid: i64,
@@ -143,7 +129,6 @@ struct IssueRow {
project_path: String,
}
/// Find issue by iid, optionally filtered by project.
fn find_issue(conn: &Connection, iid: i64, project_filter: Option<&str>) -> Result<IssueRow> {
let (sql, params): (&str, Vec<Box<dyn rusqlite::ToSql>>) = match project_filter {
Some(project) => {
@@ -201,7 +186,6 @@ fn find_issue(conn: &Connection, iid: i64, project_filter: Option<&str>) -> Resu
}
}
/// Get labels for an issue.
fn get_issue_labels(conn: &Connection, issue_id: i64) -> Result<Vec<String>> {
let mut stmt = conn.prepare(
"SELECT l.name FROM labels l
@@ -217,9 +201,7 @@ fn get_issue_labels(conn: &Connection, issue_id: i64) -> Result<Vec<String>> {
Ok(labels)
}
/// Get discussions with notes for an issue.
fn get_issue_discussions(conn: &Connection, issue_id: i64) -> Result<Vec<DiscussionDetail>> {
// First get all discussions
let mut disc_stmt = conn.prepare(
"SELECT id, individual_note FROM discussions
WHERE issue_id = ?
@@ -233,7 +215,6 @@ fn get_issue_discussions(conn: &Connection, issue_id: i64) -> Result<Vec<Discuss
})?
.collect::<std::result::Result<Vec<_>, _>>()?;
// Then get notes for each discussion
let mut note_stmt = conn.prepare(
"SELECT author_username, body, created_at, is_system
FROM notes
@@ -255,7 +236,6 @@ fn get_issue_discussions(conn: &Connection, issue_id: i64) -> Result<Vec<Discuss
})?
.collect::<std::result::Result<Vec<_>, _>>()?;
// Filter out discussions with only system notes
let has_user_notes = notes.iter().any(|n| !n.is_system);
if has_user_notes || notes.is_empty() {
discussions.push(DiscussionDetail {
@@ -268,24 +248,18 @@ fn get_issue_discussions(conn: &Connection, issue_id: i64) -> Result<Vec<Discuss
Ok(discussions)
}
/// Run the show MR command.
pub fn run_show_mr(config: &Config, iid: i64, project_filter: Option<&str>) -> Result<MrDetail> {
let db_path = get_db_path(config.storage.db_path.as_deref());
let conn = create_connection(&db_path)?;
// Find the MR
let mr = find_mr(&conn, iid, project_filter)?;
// Load labels
let labels = get_mr_labels(&conn, mr.id)?;
// Load assignees
let assignees = get_mr_assignees(&conn, mr.id)?;
// Load reviewers
let reviewers = get_mr_reviewers(&conn, mr.id)?;
// Load discussions with notes
let discussions = get_mr_discussions(&conn, mr.id)?;
Ok(MrDetail {
@@ -311,7 +285,6 @@ pub fn run_show_mr(config: &Config, iid: i64, project_filter: Option<&str>) -> R
})
}
/// Internal MR row from query.
struct MrRow {
id: i64,
iid: i64,
@@ -330,7 +303,6 @@ struct MrRow {
project_path: String,
}
/// Find MR by iid, optionally filtered by project.
fn find_mr(conn: &Connection, iid: i64, project_filter: Option<&str>) -> Result<MrRow> {
let (sql, params): (&str, Vec<Box<dyn rusqlite::ToSql>>) = match project_filter {
Some(project) => {
@@ -398,7 +370,6 @@ fn find_mr(conn: &Connection, iid: i64, project_filter: Option<&str>) -> Result<
}
}
/// Get labels for an MR.
fn get_mr_labels(conn: &Connection, mr_id: i64) -> Result<Vec<String>> {
let mut stmt = conn.prepare(
"SELECT l.name FROM labels l
@@ -414,7 +385,6 @@ fn get_mr_labels(conn: &Connection, mr_id: i64) -> Result<Vec<String>> {
Ok(labels)
}
/// Get assignees for an MR.
fn get_mr_assignees(conn: &Connection, mr_id: i64) -> Result<Vec<String>> {
let mut stmt = conn.prepare(
"SELECT username FROM mr_assignees
@@ -429,7 +399,6 @@ fn get_mr_assignees(conn: &Connection, mr_id: i64) -> Result<Vec<String>> {
Ok(assignees)
}
/// Get reviewers for an MR.
fn get_mr_reviewers(conn: &Connection, mr_id: i64) -> Result<Vec<String>> {
let mut stmt = conn.prepare(
"SELECT username FROM mr_reviewers
@@ -444,9 +413,7 @@ fn get_mr_reviewers(conn: &Connection, mr_id: i64) -> Result<Vec<String>> {
Ok(reviewers)
}
/// Get discussions with notes for an MR.
fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result<Vec<MrDiscussionDetail>> {
// First get all discussions
let mut disc_stmt = conn.prepare(
"SELECT id, individual_note FROM discussions
WHERE merge_request_id = ?
@@ -460,7 +427,6 @@ fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result<Vec<MrDiscussionD
})?
.collect::<std::result::Result<Vec<_>, _>>()?;
// Then get notes for each discussion (with DiffNote position fields)
let mut note_stmt = conn.prepare(
"SELECT author_username, body, created_at, is_system,
position_old_path, position_new_path, position_old_line,
@@ -507,7 +473,6 @@ fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result<Vec<MrDiscussionD
})?
.collect::<std::result::Result<Vec<_>, _>>()?;
// Filter out discussions with only system notes
let has_user_notes = notes.iter().any(|n| !n.is_system);
if has_user_notes || notes.is_empty() {
discussions.push(MrDiscussionDetail {
@@ -520,14 +485,11 @@ fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result<Vec<MrDiscussionD
Ok(discussions)
}
/// Format date from ms epoch.
fn format_date(ms: i64) -> String {
let iso = ms_to_iso(ms);
// Extract just the date part (YYYY-MM-DD)
iso.split('T').next().unwrap_or(&iso).to_string()
}
/// Truncate text with ellipsis (character-safe for UTF-8).
fn truncate(s: &str, max_len: usize) -> String {
if s.chars().count() <= max_len {
s.to_string()
@@ -537,7 +499,6 @@ fn truncate(s: &str, max_len: usize) -> String {
}
}
/// Wrap text to width, with indent prefix on continuation lines.
fn wrap_text(text: &str, width: usize, indent: &str) -> String {
let mut result = String::new();
let mut current_line = String::new();
@@ -569,15 +530,12 @@ fn wrap_text(text: &str, width: usize, indent: &str) -> String {
result
}
/// Print issue detail.
pub fn print_show_issue(issue: &IssueDetail) {
// Header
let header = format!("Issue #{}: {}", issue.iid, issue.title);
println!("{}", style(&header).bold());
println!("{}", "".repeat(header.len().min(80)));
println!();
// Metadata
println!("Project: {}", style(&issue.project_path).cyan());
let state_styled = if issue.state == "opened" {
@@ -603,7 +561,6 @@ pub fn print_show_issue(issue: &IssueDetail) {
println!();
// Description
println!("{}", style("Description:").bold());
if let Some(desc) = &issue.description {
let truncated = truncate(desc, 500);
@@ -615,7 +572,6 @@ pub fn print_show_issue(issue: &IssueDetail) {
println!();
// Discussions
let user_discussions: Vec<&DiscussionDetail> = issue
.discussions
.iter()
@@ -636,7 +592,6 @@ pub fn print_show_issue(issue: &IssueDetail) {
discussion.notes.iter().filter(|n| !n.is_system).collect();
if let Some(first_note) = user_notes.first() {
// First note of discussion (not indented)
println!(
" {} ({}):",
style(format!("@{}", first_note.author_username)).cyan(),
@@ -646,7 +601,6 @@ pub fn print_show_issue(issue: &IssueDetail) {
println!(" {}", wrapped);
println!();
// Replies (indented)
for reply in user_notes.iter().skip(1) {
println!(
" {} ({}):",
@@ -662,16 +616,13 @@ pub fn print_show_issue(issue: &IssueDetail) {
}
}
/// Print MR detail.
pub fn print_show_mr(mr: &MrDetail) {
// Header with draft indicator
let draft_prefix = if mr.draft { "[Draft] " } else { "" };
let header = format!("MR !{}: {}{}", mr.iid, draft_prefix, mr.title);
println!("{}", style(&header).bold());
println!("{}", "".repeat(header.len().min(80)));
println!();
// Metadata
println!("Project: {}", style(&mr.project_path).cyan());
let state_styled = match mr.state.as_str() {
@@ -735,7 +686,6 @@ pub fn print_show_mr(mr: &MrDetail) {
println!();
// Description
println!("{}", style("Description:").bold());
if let Some(desc) = &mr.description {
let truncated = truncate(desc, 500);
@@ -747,7 +697,6 @@ pub fn print_show_mr(mr: &MrDetail) {
println!();
// Discussions
let user_discussions: Vec<&MrDiscussionDetail> = mr
.discussions
.iter()
@@ -768,12 +717,10 @@ pub fn print_show_mr(mr: &MrDetail) {
discussion.notes.iter().filter(|n| !n.is_system).collect();
if let Some(first_note) = user_notes.first() {
// Print DiffNote position context if present
if let Some(pos) = &first_note.position {
print_diff_position(pos);
}
// First note of discussion (not indented)
println!(
" {} ({}):",
style(format!("@{}", first_note.author_username)).cyan(),
@@ -783,7 +730,6 @@ pub fn print_show_mr(mr: &MrDetail) {
println!(" {}", wrapped);
println!();
// Replies (indented)
for reply in user_notes.iter().skip(1) {
println!(
" {} ({}):",
@@ -799,7 +745,6 @@ pub fn print_show_mr(mr: &MrDetail) {
}
}
/// Print DiffNote position context.
fn print_diff_position(pos: &DiffNotePosition) {
let file = pos.new_path.as_ref().or(pos.old_path.as_ref());
@@ -821,11 +766,6 @@ fn print_diff_position(pos: &DiffNotePosition) {
}
}
// ============================================================================
// JSON Output Structs (with ISO timestamps for machine consumption)
// ============================================================================
/// JSON output for issue detail.
#[derive(Serialize)]
pub struct IssueDetailJson {
pub id: i64,
@@ -842,14 +782,12 @@ pub struct IssueDetailJson {
pub discussions: Vec<DiscussionDetailJson>,
}
/// JSON output for discussion detail.
#[derive(Serialize)]
pub struct DiscussionDetailJson {
pub notes: Vec<NoteDetailJson>,
pub individual_note: bool,
}
/// JSON output for note detail.
#[derive(Serialize)]
pub struct NoteDetailJson {
pub author_username: String,
@@ -897,7 +835,6 @@ impl From<&NoteDetail> for NoteDetailJson {
}
}
/// JSON output for MR detail.
#[derive(Serialize)]
pub struct MrDetailJson {
pub id: i64,
@@ -921,14 +858,12 @@ pub struct MrDetailJson {
pub discussions: Vec<MrDiscussionDetailJson>,
}
/// JSON output for MR discussion detail.
#[derive(Serialize)]
pub struct MrDiscussionDetailJson {
pub notes: Vec<MrNoteDetailJson>,
pub individual_note: bool,
}
/// JSON output for MR note detail.
#[derive(Serialize)]
pub struct MrNoteDetailJson {
pub author_username: String,
@@ -985,7 +920,6 @@ impl From<&MrNoteDetail> for MrNoteDetailJson {
}
}
/// Print issue detail as JSON.
pub fn print_show_issue_json(issue: &IssueDetail) {
let json_result = IssueDetailJson::from(issue);
match serde_json::to_string_pretty(&json_result) {
@@ -994,7 +928,6 @@ pub fn print_show_issue_json(issue: &IssueDetail) {
}
}
/// Print MR detail as JSON.
pub fn print_show_mr_json(mr: &MrDetail) {
let json_result = MrDetailJson::from(mr);
match serde_json::to_string_pretty(&json_result) {
@@ -1030,7 +963,6 @@ mod tests {
#[test]
fn format_date_extracts_date_part() {
// 2024-01-15T00:00:00Z in milliseconds
let ms = 1705276800000;
let date = format_date(ms);
assert!(date.starts_with("2024-01-15"));