Skip to content
Merged

Json #27

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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "open-ai-reviewer",
"name": "roast-my-code",

Choose a reason for hiding this comment

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

The name change from "open-ai-reviewer" to "roast-my-code" may not accurately reflect the purpose of the package. Consider a name that better represents the functionality.

"version": "1.0.0",
"description": "Open AI powered code reviews",
"description": "mean and aggressive code reviews by ChatGPT",

Choose a reason for hiding this comment

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

The description should be more professional and less aggressive. Consider rephrasing to maintain a suitable tone for a public package.

"main": "lib/main.js",
"author": "Ville Saukkonen",
"author": "Christina Martinez, based on work by Ville Saukkonen",

Choose a reason for hiding this comment

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

Attribution should be clear and concise. If the work is based on Ville Saukkonen's contributions, consider simplifying the author field to avoid confusion.

"license": "MIT",
"scripts": {
"build": "tsc",
Expand Down
29 changes: 23 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,33 @@ function createComment(
reviewComment: string;
}>
): Array<{ body: string; path: string; line: number }> {
return aiResponses.flatMap((aiResponse) => {
const comments = aiResponses.flatMap((aiResponse) => {

Choose a reason for hiding this comment

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

The variable comments is declared but not used until the return statement. Consider renaming it to something more descriptive or using it directly in the return statement to improve clarity.

if (!file.to) {
return [];
}
return {
body: aiResponse.reviewComment,
path: file.to,
line: Number(aiResponse.lineNumber),
};
// Log the AI response and the file path

Choose a reason for hiding this comment

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

The commented-out code should be removed to maintain clean code practices.

console.log("AI Response:", aiResponse);
console.log("File Path:", file.to);
console.log("Chunk:", chunk);

const lineNumber = Number(aiResponse.lineNumber);

Choose a reason for hiding this comment

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

The variable lineNumber is declared but not used until later. Consider using it directly in the return statement to improve readability.


// Ensure the line number exists in the chunk
if (chunk.changes.some((change: { ln: number; ln2: number; }) => change.ln === lineNumber || change.ln2 === lineNumber)) {
return {
body: aiResponse.reviewComment,
path: file.to,
line: lineNumber,
};
} else {
console.warn(`Line number ${lineNumber} does not exist in the diff for file ${file.to}`);
return [];
}
});

// Log the comments before returning

Choose a reason for hiding this comment

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

The log statement for comments may expose sensitive information in production. Consider removing or guarding it with a debug flag.

console.log("Comments:", comments);
return comments;
}

async function createReviewComment(
Expand Down
Loading