-
Notifications
You must be signed in to change notification settings - Fork 202
Line by line comments #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LOGAF Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/test/run/runTest.ts
if (similarityResponse.length === 0) {
return { success: false, reason: "No similar reviews found" };
}
for (const testCase of testCases) {
const result = await runTest(
testCase,
modelName,
maxPromptLength,
vectorStore
);
testResults[testCase.name] = result;
if (!result.success) {
throw new Error(`Test case ${testCase.name} failed: ${result.reason}`);
}
} LOGAF Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/args.ts
import inquirer from "inquirer";
const handleNoCommand = async () => {
// rest of the code
};
export interface ReviewArgs {
// other properties
shouldCommentPerFile: boolean;
}
// in getYargs function
.option("shouldCommentPerFile", {
description: "Enables feedback to be made on a file-by-file basis.",
type: "boolean",
default: false,
}) LOGAF Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/common/ci/utils.ts
if (repoIndex !== -1) {
return fileName.slice(repoIndex + repoName.length + 1);
} else {
throw new Error("Repo name not found in the absolute path");
}
try {
// code
} catch (error) {
console.error(
`Failed to comment on PR for feedback: ${data.feedback.details}. Error: ${error}`
);
} 🚀🔧🔀 Powered by Code Review GPT |
Test results summary:✅ [PASS] - Test case: Bad variable name SUMMARY: ✅ PASS: 4 - Tests Powered by Code Review GPT |
472c9d1
to
cb2accd
Compare
d2cbc16
to
153a43b
Compare
153a43b
to
8296a94
Compare
b6ed9ae
to
baa67de
Compare
src/review/llm/askAI.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
The
askAI
function could be simplified by removing theverbose
parameter and always logging the 'Asking the experts...' message. This would make the function easier to use and understand. -
Consider handling the error in a more user-friendly way. Instead of just logging the error, you could throw it or handle it in a way that the user can understand what went wrong.
Powered by Code Review GPT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The function
commentPerFile()
is not handling any errors that may occur during the execution ofcommentOnFile()
. Consider adding error handling to ensure that the application can recover gracefully from errors.
Example:
try {
await commentOnFile(octokit, {
feedback,
signOff,
owner,
repo,
pull_number,
commit_id,
});
} catch (error) {
console.error('Failed to comment on file:', error);
}
- The function
commentPerFile()
is doing too many things. Consider breaking it down into smaller functions to improve readability and maintainability.
Powered by Code Review GPT
2358f1c
to
883be0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Consider adding error handling for the case where
yargs.model
is not a string. This could potentially cause a runtime error ifyargs.model
is not a string.
const modelName = typeof yargs.model === 'string' ? yargs.model : 'defaultModelName';
- Consider adding a default case for when neither
isCi && !shouldCommentPerFile
norisCi && shouldCommentPerFile
are true. This could help prevent unexpected behavior.
if (isCi && !shouldCommentPerFile) {
await commentOnPR(response, signOff);
} else if (isCi && shouldCommentPerFile) {
await commentPerFile(feedbacks, signOff);
} else {
// Default case
}
Powered by Code Review GPT
Would be great to document this flag in the readme. Looks great :) |
1265efc
to
51bc1a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the default behaviour we want for new people running the setup script?
I see 3 possibilities:
- still setup the CI to have 1 big comment
- enable per file comment by default
- make people choose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please not enable this by default. It should sit behind a flag till we add some more refined functionality :)
package.json
Outdated
@@ -9,7 +9,7 @@ | |||
"types": "dist/index.d.ts", | |||
"scripts": { | |||
"start": "ts-node ./src/index.ts review", | |||
"start-ci": "ts-node ./src/index.ts review --ci", | |||
"start-ci": "ts-node ./src/index.ts review --ci --commentPerFile", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to add this to its own script
src/common/ci/commentPerFile.ts
Outdated
|
||
// Comment all feedback line by line | ||
for (const feedback of feedbacks) { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested try catch blocks are not necessary
need to decide on default behavior first
src/review/index.ts
Outdated
_: (string | number)[]; | ||
$0: string; | ||
} | ||
|
||
export const review = async (yargs: ReviewArgs) => { | ||
const isCi = yargs.ci; | ||
const shouldCommentPerFile = yargs.commentPerFile; | ||
if (shouldCommentPerFile && !isCi) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should happen in the yargs file
package.json
Outdated
@@ -9,7 +9,8 @@ | |||
"types": "dist/index.d.ts", | |||
"scripts": { | |||
"start": "ts-node ./src/index.ts review", | |||
"start-ci": "ts-node ./src/index.ts review --ci", | |||
"start-ci": "ts-node ./src/index.ts review --ci --commentPerFile", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this flag from here.
9a54324
to
a032baa
Compare
No description provided.