Skip to content

Commit 270f80c

Browse files
committed
fix(review): add file path and line number to review schema
1 parent 4f5a524 commit 270f80c

1 file changed

Lines changed: 28 additions & 20 deletions

File tree

src/commands/review.rs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ struct ReviewIssue {
126126
category: String,
127127
title: String,
128128
description: String,
129+
file_path: Option<String>,
130+
line_number: Option<u32>,
129131
}
130132

131133
async fn perform_code_review_chunked(
@@ -352,18 +354,13 @@ fn create_review_prompt(
352354
- CRITICAL: Security vulnerabilities, data corruption risks, breaking changes\n\
353355
- HIGH: Performance issues, major bugs, significant technical debt\n\
354356
- MEDIUM: Code quality issues, minor bugs, style violations\n\
355-
- LOW: Suggestions, optimizations, documentation improvements\n\n\
356-
COMPLEXITY LEVELS:\n\
357-
- low: Simple, straightforward code\n\
358-
- medium: Moderate complexity with some logic\n\
359-
- high: Complex logic, multiple responsibilities\n\
360-
- very_high: Highly complex, difficult to understand\n\n\
361-
MAINTAINABILITY LEVELS:\n\
362-
- poor: Difficult to modify, lacks structure\n\
363-
- fair: Some issues but manageable\n\
364-
- good: Well-structured, easy to understand\n\
365-
- excellent: Exemplary code quality\n\n\
366-
File Statistics:\n\
357+
- LOW: Suggestions, optimizations, documentation improvements\\n\\n\\\
358+
LOCATION INFORMATION:\\n\\\
359+
For each issue, provide the specific file path and line number where the issue occurs.\\n\\\
360+
- file_path: The relative path to the file (e.g., 'src/main.rs', 'lib/utils.js')\\n\\\
361+
- line_number: The specific line number where the issue is found\\n\\\
362+
Extract this information from the git diff context. If you cannot determine the exact location, omit these fields.\\n\\n\\\
363+
File Statistics:\\n\\
367364
{}\n\n\
368365
Git Diff:\n\
369366
```\n{}\n```{}\n\n\
@@ -433,6 +430,8 @@ fn create_fallback_review(
433430
description:
434431
"The automated review could not complete fully. Manual review recommended."
435432
.to_string(),
433+
file_path: None,
434+
line_number: None,
436435
}],
437436
recommendations: vec![
438437
"Consider running the review again".to_string(),
@@ -468,8 +467,15 @@ fn display_review_results(review: &ReviewResult, severity_filter: &str) {
468467
_ => "❓",
469468
};
470469

471-
println!("\n{} {} [{}]", severity_emoji, issue.title, issue.severity);
470+
println!("\\n{} {} [{}]", severity_emoji, issue.title, issue.severity);
472471
println!(" Category: {}", issue.category);
472+
if let Some(file_path) = &issue.file_path {
473+
if let Some(line_num) = issue.line_number {
474+
println!(" Location: {} (Line {})", file_path, line_num);
475+
} else {
476+
println!(" File: {}", file_path);
477+
}
478+
}
473479
println!(" Description: {}", issue.description);
474480
}
475481
}
@@ -555,13 +561,15 @@ async fn call_llm_for_review(prompt: &str, config: &Config) -> Result<String> {
555561
"type": "array",
556562
"items": {
557563
"type": "object",
558-
"properties": {
559-
"severity": {"type": "string"},
560-
"category": {"type": "string"},
561-
"title": {"type": "string"},
562-
"description": {"type": "string"}
563-
},
564-
"required": ["severity", "category", "title", "description"],
564+
"properties": {
565+
"severity": {"type": "string"},
566+
"category": {"type": "string"},
567+
"title": {"type": "string"},
568+
"description": {"type": "string"},
569+
"file_path": {"type": ["string", "null"]},
570+
"line_number": {"type": ["integer", "null"]}
571+
},
572+
"required": ["severity", "category", "title", "description", "file_path", "line_number"],
565573
"additionalProperties": false
566574
}
567575
},

0 commit comments

Comments
 (0)