repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
ai-pr-reviewer
github_2023
typescript
181
coderabbitai
github-actions[bot]
@@ -638,31 +600,93 @@ ${comment_chain} const reviewPromises = [] const skipped_files_to_review = [] - for (const [filename, file_content, , patches] of files_to_review) { - if ( - options.max_files_to_review <= 0 || - reviewPromises.length < options.max_files_to_review - ) { - reviewPromises.push( - openai_concurrency_limit(async () => - do_review(filename, file_content, patches) + + if (options.summary_only !== true) { + for (const [filename, file_content, , patches] of files_to_review) { + if ( + options.max_files_to_review <= 0 || + reviewPromises.length < options.max_files_to_review + ) { + reviewPromises.push( + openai_concurrency_limit(async () => + do_review(filename, file_content, patches) + ) ) - ) - } else { - skipped_files_to_review.push(filename) + } else { + skipped_files_to_review.push(filename) + } } + + await Promise.all(reviewPromises)
:robot: OpenAI The `for` loop on lines 605-618 can be simplified by using the `Array.slice()` method to limit the number of files to review. This would eliminate the need for the `skipped_files_to_review` array and the `if` statement on line 616. Here's an example: ```javascript const filesToReview = options.max_files_to_review > 0 ? files_to_review.slice(0, options.max_files_to_review) : files_to_review; const reviewPromises = filesToReview.map(([filename, file_content, , patches]) => openai_concurrency_limit(async () => do_review(filename, file_content, patches)) ); await Promise.all(reviewPromises); ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
181
coderabbitai
github-actions[bot]
@@ -638,31 +600,93 @@ ${comment_chain} const reviewPromises = [] const skipped_files_to_review = [] - for (const [filename, file_content, , patches] of files_to_review) { - if ( - options.max_files_to_review <= 0 || - reviewPromises.length < options.max_files_to_review - ) { - reviewPromises.push( - openai_concurrency_limit(async () => - do_review(filename, file_content, patches) + + if (options.summary_only !== true) { + for (const [filename, file_content, , patches] of files_to_review) { + if ( + options.max_files_to_review <= 0 || + reviewPromises.length < options.max_files_to_review + ) { + reviewPromises.push( + openai_concurrency_limit(async () => + do_review(filename, file_content, patches) + ) ) - ) - } else { - skipped_files_to_review.push(filename) + } else { + skipped_files_to_review.push(filename) + } } + + await Promise.all(reviewPromises) } - await Promise.all(reviewPromises) + let summarize_comment = `${summarize_final_response} + +--- + +### Chat with 🤖 OpenAI Bot (\`@openai\`) +- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file. +- Invite the bot into a review comment chain by tagging \`@openai\` in a reply. + +### Code suggestions +- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned. +- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off. + +--- + +${ + filter_ignored_files.length > 0 + ? ` +<details> +<summary>Files ignored due to filter (${filter_ignored_files.length})</summary> + +### Ignored files + +* ${filter_ignored_files.map(file => file.filename).join('\n* ')} + +</details> +` + : '' +} + +${ + skipped_files_to_summarize.length > 0 + ? ` +<details> +<summary>Files not summarized due to max files limit (${ + skipped_files_to_summarize.length + })</summary> + +### Not summarized + +* ${skipped_files_to_summarize.join('\n* ')} + +</details> +` + : '' +} + +${ + summaries_failed.length > 0 + ? ` +<details> +<summary>Files not summarized due to errors (${ + summaries_failed.length + })</summary> + +### Failed to summarize + +* ${summaries_failed.join('\n* ')} + +</details> +` + : '' +}
:robot: OpenAI The `summarize_comment` variable can be set directly to the final summary comment without the need for the `if` statement on line 604. The `filter_ignored_files`, `skipped_files_to_summarize`, and `summaries_failed` sections can be moved to the end of the comment. Here's an example: ```javascript const summarize_comment = `${summarize_final_response} <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
181
coderabbitai
github-actions[bot]
@@ -638,61 +600,132 @@ ${comment_chain} const reviewPromises = [] const skipped_files_to_review = [] - for (const [filename, file_content, , patches] of files_to_review) { - if ( - options.max_files_to_review <= 0 || - reviewPromises.length < options.max_files_to_review - ) { - reviewPromises.push( - openai_concurrency_limit(async () => - do_review(filename, file_content, patches) + + if (options.summary_only !== true) { + for (const [filename, file_content, , patches] of files_to_review) { + if ( + options.max_files_to_review <= 0 || + reviewPromises.length < options.max_files_to_review + ) { + reviewPromises.push( + openai_concurrency_limit(async () => + do_review(filename, file_content, patches) + ) ) - ) - } else { - skipped_files_to_review.push(filename) + } else { + skipped_files_to_review.push(filename) + } } + + await Promise.all(reviewPromises) } - await Promise.all(reviewPromises) + let summarize_comment = `${summarize_final_response} + +--- + +### Chat with 🤖 OpenAI Bot (\`@openai\`) +- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file. +- Invite the bot into a review comment chain by tagging \`@openai\` in a reply. + +### Code suggestions +- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned. +- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off. + +--- + +${ + filter_ignored_files.length > 0 + ? ` +<details> +<summary>Files ignored due to filter (${filter_ignored_files.length})</summary> + +### Ignored files + +* ${filter_ignored_files.map(file => file.filename).join('\n* ')} + +</details> +` + : '' +} + +${ + skipped_files_to_summarize.length > 0 + ? ` +<details> +<summary>Files not summarized due to max files limit (${ + skipped_files_to_summarize.length + })</summary> + +### Not summarized + +* ${skipped_files_to_summarize.join('\n* ')} + +</details> +` + : '' +} + +${ + summaries_failed.length > 0 + ? ` +<details> +<summary>Files not summarized due to errors (${ + summaries_failed.length + })</summary> + +### Failed to summarize + +* ${summaries_failed.join('\n* ')} - // comment about skipped files for review and summarize - if (skipped_files_to_review.length > 0) { - // make bullet points for skipped files - const comment = ` - ${ - skipped_files_to_review.length > 0 - ? `<details> -<summary>Files not reviewed due to max files limit (${ - skipped_files_to_review.length - })</summary> +</details> +` + : '' +} + +${ + skipped_files_to_review.length > 0 + ? ` +<details> +<summary>Files not reviewed due to max files limit in this run (${ + skipped_files_to_review.length + })</summary> ### Not reviewed * ${skipped_files_to_review.join('\n* ')} </details> ` - : '' - } + : '' +} - ${ - reviews_failed.length > 0 - ? `<details> -<summary>Files not reviewed due to errors (${reviews_failed.length})</summary> +${
:robot: OpenAI The new code adds a conditional statement that generates a details element with a summary and list of skipped files if there are any. The formatting of the conditional statement is improved, but it could be further simplified by using a ternary operator instead of an if/else block. Additionally, the indentation of the details element should be adjusted to match the rest of the code. ```suggestion ${skipped_files_to_review.length > 0 ? ` <details> <summary>Files not reviewed due to max files limit in this run (${skipped_files_to_review.length})</summary> ### Not reviewed * ${skipped_files_to_review.join('\n* ')} </details> ` : ''} ``` <!-- This is an auto-generated reply by OpenAI -->
ai-pr-reviewer
github_2023
typescript
181
coderabbitai
github-actions[bot]
@@ -883,3 +916,84 @@ function parseReview(response: string, debug = false): Review[] { return reviews } + +const commit_ids_marker_start = '<!-- commit_ids_reviewed_start -->' +const commit_ids_marker_end = '<!-- commit_ids_reviewed_end -->' + +// function that takes a comment body and returns the list of commit ids that have been reviewed +// commit ids are comments between the commit_ids_reviewed_start and commit_ids_reviewed_end markers +// <!-- [commit_id] --> +function getReviewedCommitIds(commentBody: string): string[] { + const start = commentBody.indexOf(commit_ids_marker_start) + const end = commentBody.indexOf(commit_ids_marker_end) + if (start === -1 || end === -1) { + return [] + } + const ids = commentBody.substring(start + commit_ids_marker_start.length, end) + // remove the <!-- and --> markers from each id and extract the id and remove empty strings + return ids + .split('<!--') + .map(id => id.replace('-->', '').trim()) + .filter(id => id !== '') +} + +// get review commit ids comment block from the body as a string +// including markers +function getReviewedCommitIdsBlock(commentBody: string): string { + const start = commentBody.indexOf(commit_ids_marker_start) + const end = commentBody.indexOf(commit_ids_marker_end) + if (start === -1 || end === -1) { + return '' + } + return commentBody.substring(start, end + commit_ids_marker_end.length) +} + +// add a commit id to the list of reviewed commit ids +// if the marker doesn't exist, add it +function addReviewedCommitId(commentBody: string, commitId: string): string { + const start = commentBody.indexOf(commit_ids_marker_start) + const end = commentBody.indexOf(commit_ids_marker_end) + if (start === -1 || end === -1) { + return `${commentBody}\n${commit_ids_marker_start}\n<!-- ${commitId} -->\n${commit_ids_marker_end}` + } + const ids = commentBody.substring(start + commit_ids_marker_start.length, end) + return `${commentBody.substring( + 0, + start + commit_ids_marker_start.length + )}${ids}<!-- ${commitId} -->\n${commentBody.substring(end)}`
:robot: OpenAI The new code replaces a newline character with an HTML comment. This change is unnecessary and does not improve the readability of the code. Please revert this change. ```suggestion return `${commentBody.substring( 0, start + commit_ids_marker_start.length )}${ids}\n${commitId}\n${commentBody.substring(end)}` } ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
181
coderabbitai
github-actions[bot]
@@ -554,6 +516,7 @@ Changes for review are below: ) if (all_chains.length > 0) { + core.info(`Found comment chains: ${all_chains} for ${filename}`) comment_chain = all_chains } else { comment_chain = ''
:robot: OpenAI The `if` statement can be simplified by directly assigning `all_chains` to `comment_chain`. There's no need for an `else` block that assigns an empty string to `comment_chain`. ```suggestion comment_chain = all_chains; ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -146,12 +146,12 @@ export const codeReview = async ( continue }
:robot: OpenAI The variable name `hunks_str` is not descriptive enough. Consider renaming it to something like `formatted_hunks`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -146,12 +146,12 @@ export const codeReview = async ( continue } const hunks_str = ` ----new_hunk_for_review--- +---new_hunk--- \`\`\` ${hunks.new_hunk} \`\`\` ----old_hunk_for_context--- +---old_hunk--- \`\`\` ${hunks.old_hunk} \`\`\`
:robot: OpenAI The new hunk seems fine. No issues detected. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -387,17 +387,17 @@ ${ // Pack instructions ins.patches += `
:robot: OpenAI The variable name `ins` is not descriptive enough. Consider renaming it to something like `packed_instructions`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -387,17 +387,17 @@ ${ // Pack instructions ins.patches += ` Format for changes: - ---new_hunk_for_review--- + ---new_hunk--- \`\`\` <new hunk annotated with line numbers> \`\`\` - ---old_hunk_for_context--- + ---old_hunk--- \`\`\` <old hunk that was replaced by the new hunk above> \`\`\`
:robot: OpenAI The new hunk seems fine. No issues detected. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -406,9 +406,11 @@ Format for changes: ... The above format for changes consists of multiple change sections. -Each change section consists of a new hunk (annotated with line numbers), -an old hunk (that was replaced with new hunk) and optionally, comment -chains for context. +Each change section consists of a new hunk (annotated with line numbers) +and an old hunk. Note that the code in old_hunk does not exist anymore +as it was replaced by the new hunk. The old_hunk is only included for +context. The new hunk is the code that you should review. Optionally, +existing review comment chains are included for additional context.
:robot: OpenAI The new hunk provides a good overview of the changes made and instructions for reviewing the code. No issues detected. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -434,7 +436,7 @@ Important instructions: - If needed, provide a replacement suggestion using fenced code blocks with the \`suggestion\` as the language identifier. The line number range in the review section must map exactly to the line number range (inclusive) - that need to be replaced within a new_hunk_for_review. + that need to be replaced within a new_hunk. For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk need to be replaced with new code, then the line number range must be the
:robot: OpenAI The instructions are clear and concise. No issues detected. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -474,15 +476,15 @@ Response format expected: ... Example changes: - ---new_hunk_for_review--- + ---new_hunk--- 1: def add(x, y): 2: z = x+y 3: retrn z 4: 5: def multiply(x, y): 6: return x * y - ---old_hunk_for_context--- + ---old_hunk--- def add(x, y): return x + y
:robot: OpenAI The example changes seem fine. No issues detected. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
180
coderabbitai
github-actions[bot]
@@ -577,7 +579,7 @@ ${patch} ` if (comment_chain !== '') { ins.patches += ` ----comment_chains_for_review--- +---comment_chains--- \`\`\` ${comment_chain} \`\`\`
:robot: OpenAI The variable name `comment_chain` is not descriptive enough. Consider renaming it to something like `formatted_comment_chain`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
179
coderabbitai
github-actions[bot]
@@ -18,6 +18,8 @@ const octokit = new RetryOctokit({auth: `token ${token}`}) const context = github.context const repo = context.repo +const ignore_keyword = '@opanai: ignore' +
:robot: OpenAI The `ignore_keyword` variable is misspelled as `@opanai: ignore`. Please correct the spelling to `@openai: ignore`. ```suggestion const ignore_keyword = '@openai: ignore' ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
179
coderabbitai
github-actions[bot]
@@ -49,6 +51,19 @@ export const codeReview = async ( context.payload.pull_request.body ) } + + // if the description contains ignore_keyword, skip + if (inputs.description.includes(ignore_keyword)) { + core.info(`Skipped: description contains ignore_keyword`) + // post a comment to notify the user + await commenter.comment( + `Skipped: ignored by the user`, + SUMMARIZE_TAG, + 'replace'
:robot: OpenAI It's good to have a way to skip pull requests, but it would be better to use a more explicit keyword than just "ignore". This will help prevent confusion and ensure that users are intentionally skipping the review. Consider changing the keyword to something like "@openai: skip_review". ```suggestion const skip_keyword = '@openai: skip_review' // ... if (inputs.description.includes(skip_keyword)) { core.info(`Skipped: description contains skip_keyword`) // post a comment to notify the user await commenter.comment( `Skipped: review skipped by the user`, SUMMARIZE_TAG, 'replace' ) return } ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
179
coderabbitai
github-actions[bot]
@@ -18,6 +18,8 @@ const octokit = new RetryOctokit({auth: `token ${token}`}) const context = github.context const repo = context.repo
:robot: OpenAI The `repo` variable is not used in this function. Consider removing it. ```suggestion const context = github.context const ignore_keyword = '@opanai: ignore' export const codeReview = async ( lightBot: Bot, heavyBot: Bot, ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
179
coderabbitai
github-actions[bot]
@@ -49,6 +51,20 @@ export const codeReview = async ( context.payload.pull_request.body ) } + + core.info(`check description: ${inputs.description}`) + // if the description contains ignore_keyword, skip + if (inputs.description.includes(ignore_keyword)) { + core.info(`Skipped: description contains ignore_keyword`) + // post a comment to notify the user + await commenter.comment( + `Skipped: ignored by the user`, + SUMMARIZE_TAG, + 'replace' + ) + return + } +
:robot: OpenAI Consider extracting the check for the ignore keyword into a separate function to improve modularity and readability. Additionally, consider using `startsWith` instead of `includes` to ensure that only the exact keyword is matched. ```suggestion async function shouldSkipReview(description: string): Promise<boolean> { const ignore_keyword = '@openai: ignore' return description.startsWith(ignore_keyword) } // ... core.info(`check description: ${inputs.description}`) if (await shouldSkipReview(inputs.description)) { core.info(`Skipped: description contains ignore_keyword`) // post a comment to notify the user await commenter.comment( `Skipped: ignored by the user`, SUMMARIZE_TAG, 'replace' ) return } ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
178
coderabbitai
github-actions[bot]
@@ -18,6 +18,8 @@ const octokit = new RetryOctokit({auth: `token ${token}`}) const context = github.context const repo = context.repo
:robot: OpenAI The `repo` variable is not used in this function. Consider removing it. ```suggestion const context = github.context const ignore_keyword = '@opanai: ignore' export const codeReview = async ( lightBot: Bot, heavyBot: Bot, ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
178
coderabbitai
github-actions[bot]
@@ -49,6 +51,19 @@ export const codeReview = async ( context.payload.pull_request.body ) } + + // if the description contains ignore_keyword, skip + if (inputs.description.includes(ignore_keyword)) { + core.info(`Skipped: description contains ignore_keyword`) + // post a comment to notify the user + await commenter.comment( + `Skipped: ignored by the user`, + SUMMARIZE_TAG, + 'replace'
:robot: OpenAI Consider extracting the logic for ignoring pull requests into a separate function to improve modularity and readability. Also, consider using a more descriptive name for the `inputs` parameter. ```suggestion async function shouldIgnorePullRequest(inputs: {description: string}): Promise<boolean> { const ignore_keyword = '@openai: ignore' if (inputs.description.includes(ignore_keyword)) { core.info(`Skipped: description contains ignore_keyword`) // post a comment to notify the user await commenter.comment( `Skipped: ignored by the user`, SUMMARIZE_TAG, 'replace' ) return true } return false } // ... if (await shouldIgnorePullRequest({description: inputs.description})) { return } ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
177
coderabbitai
github-actions[bot]
@@ -415,13 +415,12 @@ Important instructions: chain when reviewing the new hunk.
:robot: OpenAI Consider rephrasing the sentence to "When reviewing the new hunk, consider the context provided by the old hunk and associated comment chain." for clarity. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
177
coderabbitai
github-actions[bot]
@@ -415,13 +415,12 @@ Important instructions: chain when reviewing the new hunk. - Use Markdown format for review comment text. - Fenced code blocks must be used for new content and replacement - code/text snippets. -- If you have a suggestion for replacing the code between the specified - line number range, please include it in a fenced code block with the - \`suggestion\` as the language identifier. The line number range + code/text snippets.
:robot: OpenAI Consider adding a note about using fenced code blocks for code snippets in review comments as well. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
177
coderabbitai
github-actions[bot]
@@ -102,10 +102,10 @@ inputs: - Complexity - Optimization - In general, refrain from making noisy comments such as on minor - code style issues, compliments, missing documentation, etc. - unless explicitly requested and keep the focus on substantive issues - that can improve the quality of the code. + Refrain from addressing minor code style issues, compliments, or missing + comments/documentation, unless explicitly requested. Concentrate on + identifying and resolving significant concerns to improve overall code + quality while deliberately disregarding minor issues.
:robot: OpenAI The text is identical to the original. No changes needed. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
177
coderabbitai
github-actions[bot]
@@ -415,13 +415,12 @@ Important instructions: chain when reviewing the new hunk. - Use Markdown format for review comment text. - Fenced code blocks must be used for new content and replacement - code/text snippets. -- If you have a suggestion for replacing the code between the specified - line number range, please include it in a fenced code block with the - \`suggestion\` as the language identifier. The line number range + code/text snippets. +- If needed, provide a replacement suggestion using fenced code blocks + with the \`suggestion\` as the language identifier. The line number range in the review section must map exactly to the line number range (inclusive) - that need to be replaced within a new_hunk_for_review. For instance, if 2 - lines of code in a hunk need to be replaced with 15 lines + that need to be replaced within a new_hunk_for_review. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk need to be replaced with new code, then the line number range must be the entire hunk. Replacement suggestions should be complete units that can be
:robot: OpenAI The new hunk provides additional information about how to review the code changes. However, it would be helpful to clarify that fenced code blocks should only be used for replacement suggestions and new content, not for general comments. Additionally, it might be useful to provide an example of a replacement suggestion using fenced code blocks with the `suggestion` language identifier. ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section---
:robot: OpenAI The line is not needed and can be removed. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out
:robot: OpenAI Consider rephrasing the second sentence to "Your task is to perform a line-by-line review of the new hunks and identify any substantive issues within the specified line number ranges." <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out + substantive issues in those line number ranges. When commenting, + you will need to provide the exact line number range (inclusive) + for each issue that is detected.
:robot: OpenAI Consider rephrasing the first sentence to "For each issue you identify, please provide the exact line number range (inclusive) where the issue occurs." <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out + substantive issues in those line number ranges. When commenting, + you will need to provide the exact line number range (inclusive) + for each issue that is detected. +- Only respond in the below response format (consisting of review + sections) and nothing else. Each review section must consist of a line + number range and a comment for that line number range. Optionally, + you can include a single replacement suggestion snippet and/or multiple + new code snippets in the review comment. There's a separator between review + sections. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the code changes in GitHub pull request. +- Consider the context provided by the old hunk and associated comment + chain when reviewing the new hunk. +- Use Markdown format for review comment text. +- Fenced code blocks must be used for new content and replacement + code/text snippets. +- If needed, provide a replacement suggestion using fenced code blocks + with the \`suggestion\` as the language identifier. The line number range + in the review section must map exactly to the line number range (inclusive) + that need to be replaced within a new_hunk_for_review. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines + of code, the line number range must be those exact 2 lines. If an entire hunk + need to be replaced with new code, then the line number range must be the + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. +- Replacement code/text snippets must be complete and correctly + formatted. Each replacement suggestion must be provided as a separate review + section with relevant line number ranges. +- If needed, suggest new code using the correct language identifier in the + fenced code blocks. These snippets may be added to a different file, such + as test cases. Multiple new code snippets are allowed within a single + review section. +- Do not annotate code snippets with line numbers inside the code blocks. +- If there are no substantive issues detected at a line range, simply + comment "LGTM!" for the respective line range in a review section and + avoid additional commentary/compliments. +- Review your comments and line number ranges at least 3 times before sending + the final response to ensure accuracy of line number ranges and replacement + snippets.
:robot: OpenAI Consider rephrasing the sentence to "Before submitting your final response, please review your comments and line number ranges at least three times to ensure their accuracy and completeness." <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out + substantive issues in those line number ranges. When commenting, + you will need to provide the exact line number range (inclusive) + for each issue that is detected. +- Only respond in the below response format (consisting of review + sections) and nothing else. Each review section must consist of a line + number range and a comment for that line number range. Optionally, + you can include a single replacement suggestion snippet and/or multiple + new code snippets in the review comment. There's a separator between review + sections. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the code changes in GitHub pull request. +- Consider the context provided by the old hunk and associated comment + chain when reviewing the new hunk. +- Use Markdown format for review comment text. +- Fenced code blocks must be used for new content and replacement + code/text snippets. +- If needed, provide a replacement suggestion using fenced code blocks + with the \`suggestion\` as the language identifier. The line number range + in the review section must map exactly to the line number range (inclusive) + that need to be replaced within a new_hunk_for_review. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines + of code, the line number range must be those exact 2 lines. If an entire hunk + need to be replaced with new code, then the line number range must be the + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. +- Replacement code/text snippets must be complete and correctly + formatted. Each replacement suggestion must be provided as a separate review + section with relevant line number ranges. +- If needed, suggest new code using the correct language identifier in the + fenced code blocks. These snippets may be added to a different file, such + as test cases. Multiple new code snippets are allowed within a single + review section. +- Do not annotate code snippets with line numbers inside the code blocks. +- If there are no substantive issues detected at a line range, simply + comment "LGTM!" for the respective line range in a review section and + avoid additional commentary/compliments. +- Review your comments and line number ranges at least 3 times before sending + the final response to ensure accuracy of line number ranges and replacement + snippets. + +Response format expected: + <start_line_number>-<end_line_number>: + <review comment> + --- + <start_line_number>-<end_line_number>:
:robot: OpenAI Consider rephrasing the sentence to "For each identified issue, please provide a comment and the corresponding line number range (inclusive)." <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out + substantive issues in those line number ranges. When commenting, + you will need to provide the exact line number range (inclusive) + for each issue that is detected. +- Only respond in the below response format (consisting of review + sections) and nothing else. Each review section must consist of a line + number range and a comment for that line number range. Optionally, + you can include a single replacement suggestion snippet and/or multiple + new code snippets in the review comment. There's a separator between review + sections. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the code changes in GitHub pull request. +- Consider the context provided by the old hunk and associated comment + chain when reviewing the new hunk. +- Use Markdown format for review comment text. +- Fenced code blocks must be used for new content and replacement + code/text snippets. +- If needed, provide a replacement suggestion using fenced code blocks + with the \`suggestion\` as the language identifier. The line number range + in the review section must map exactly to the line number range (inclusive) + that need to be replaced within a new_hunk_for_review. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines + of code, the line number range must be those exact 2 lines. If an entire hunk + need to be replaced with new code, then the line number range must be the + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. +- Replacement code/text snippets must be complete and correctly + formatted. Each replacement suggestion must be provided as a separate review + section with relevant line number ranges. +- If needed, suggest new code using the correct language identifier in the + fenced code blocks. These snippets may be added to a different file, such + as test cases. Multiple new code snippets are allowed within a single + review section. +- Do not annotate code snippets with line numbers inside the code blocks. +- If there are no substantive issues detected at a line range, simply + comment "LGTM!" for the respective line range in a review section and + avoid additional commentary/compliments. +- Review your comments and line number ranges at least 3 times before sending + the final response to ensure accuracy of line number ranges and replacement + snippets. + +Response format expected: + <start_line_number>-<end_line_number>: + <review comment> + --- + <start_line_number>-<end_line_number>: + <review comment> + \`\`\`suggestion + <code/text that replaces everything between start_line_number and end_line_number> + \`\`\` + --- + <start_line_number>-<end_line_number>: + <review comment>
:robot: OpenAI Consider rephrasing the sentence to "If you have a suggestion for replacing the code between the specified line number range, please include it in a fenced code block with the `suggestion` language identifier." <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,99 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out + substantive issues in those line number ranges. When commenting, + you will need to provide the exact line number range (inclusive) + for each issue that is detected. +- Only respond in the below response format (consisting of review + sections) and nothing else. Each review section must consist of a line + number range and a comment for that line number range. Optionally, + you can include a single replacement suggestion snippet and/or multiple + new code snippets in the review comment. There's a separator between review + sections. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the code changes in GitHub pull request. +- Consider the context provided by the old hunk and associated comment + chain when reviewing the new hunk. +- Use Markdown format for review comment text. +- Fenced code blocks must be used for new content and replacement + code/text snippets. +- If needed, provide a replacement suggestion using fenced code blocks + with the \`suggestion\` as the language identifier. The line number range + in the review section must map exactly to the line number range (inclusive) + that need to be replaced within a new_hunk_for_review. + For instance, if 2 lines of code in a hunk need to be replaced with 15 lines + of code, the line number range must be those exact 2 lines. If an entire hunk + need to be replaced with new code, then the line number range must be the + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. +- Replacement code/text snippets must be complete and correctly + formatted. Each replacement suggestion must be provided as a separate review + section with relevant line number ranges. +- If needed, suggest new code using the correct language identifier in the + fenced code blocks. These snippets may be added to a different file, such + as test cases. Multiple new code snippets are allowed within a single + review section. +- Do not annotate code snippets with line numbers inside the code blocks. +- If there are no substantive issues detected at a line range, simply + comment "LGTM!" for the respective line range in a review section and + avoid additional commentary/compliments. +- Review your comments and line number ranges at least 3 times before sending + the final response to ensure accuracy of line number ranges and replacement + snippets. + +Response format expected: + <start_line_number>-<end_line_number>: + <review comment> + --- + <start_line_number>-<end_line_number>: + <review comment> + \`\`\`suggestion + <code/text that replaces everything between start_line_number and end_line_number> + \`\`\` + --- + <start_line_number>-<end_line_number>: + <review comment> + \`\`\`<language> + <new code snippet> + \`\`\` + --- + ... + +Example changes: + ---new_hunk_for_review--- + 1: def add(x, y): + 2: z = x+y + 3: retrn z + 4: + 5: def multiply(x, y): + 6: return x * y + + ---old_hunk_for_context--- + def add(x, y): + return x + y
:robot: OpenAI Consider rephrasing the sentence to "This is the old hunk that was replaced by the new hunk above." <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
176
coderabbitai
github-actions[bot]
@@ -390,12 +390,100 @@ Format for changes: ---end_change_section--- ... -The above format for changes consistes of multiple change sections. +The above format for changes consists of multiple change sections. Each change section consists of a new hunk (annotated with line numbers), an old hunk (that was replaced with new hunk) and optionally, comment chains for context. -Hunks for review are below: +Important instructions: +- Your task is to do a line by line review of new hunks and point out + substantive issues in those line number ranges. For each issue you + identify, please provide the exact line number range (inclusive) where + the issue occurs. +- Only respond in the below response format (consisting of review + sections) and nothing else. Each review section must consist of a line + number range and a review comment for that line number range. Optionally, + you can include a single replacement suggestion snippet and/or multiple + new code snippets in the review comment. There's a separator between review + sections. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the code changes in GitHub pull request. +- Consider the context provided by the old hunk and associated comment + chain when reviewing the new hunk. +- Use Markdown format for review comment text. +- Fenced code blocks must be used for new content and replacement + code/text snippets. +- If you have a suggestion for replacing the code between the specified + line number range, please include it in a fenced code block with the + \`suggestion\` as the language identifier. The line number range + in the review section must map exactly to the line number range (inclusive) + that need to be replaced within a new_hunk_for_review. For instance, if 2 + lines of code in a hunk need to be replaced with 15 lines + of code, the line number range must be those exact 2 lines. If an entire hunk + need to be replaced with new code, then the line number range must be the + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. +- Replacement code/text snippets must be complete and correctly + formatted. Each replacement suggestion must be provided as a separate review + section with relevant line number ranges. +- If needed, suggest new code using the correct language identifier in the + fenced code blocks. These snippets may be added to a different file, such + as test cases. Multiple new code snippets are allowed within a single + review section. +- Do not annotate code snippets with line numbers inside the code blocks. +- If there are no substantive issues detected at a line range, simply + comment "LGTM!" for the respective line range in a review section and + avoid additional commentary/compliments. +- Review your comments and line number ranges at least 3 times before sending + the final response to ensure accuracy of line number ranges and replacement + snippets. +
:robot: OpenAI The instructions provided in this hunk are clear and comprehensive. No issues found. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
175
coderabbitai
github-actions[bot]
@@ -497,8 +497,8 @@ Instructions for you: - Only respond in the below response format (consisting of review sections) and nothing else. Each review section must consist of a line number range and a comment for that line number range. Optionally, - you can include a single replacement suggestion snippet or new code - snippets in the review comment. There's a separator between review + you can include a single replacement suggestion snippet and/or multiple + new code snippets in the review comment. There's a separator between review sections. - It's important that line number ranges for each review section must
:robot: OpenAI The sentence is incomplete. Please complete it. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
175
coderabbitai
github-actions[bot]
@@ -517,15 +517,19 @@ Instructions for you: For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk
:robot: OpenAI The sentence is too long. Please break it down into smaller sentences. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
175
coderabbitai
github-actions[bot]
@@ -517,15 +517,19 @@ Instructions for you: For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk need to be replaced with new code, then the line number range must be the - entire hunk. + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. - Replacement code/text snippets must be complete and correctly formatted. Each replacement suggestion must be provided as a separate review section with relevant line number ranges.
:robot: OpenAI Please clarify what you mean by "relevant line number ranges". <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
175
coderabbitai
github-actions[bot]
@@ -517,15 +517,19 @@ Instructions for you: For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk need to be replaced with new code, then the line number range must be the - entire hunk. + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. - Replacement code/text snippets must be complete and correctly formatted. Each replacement suggestion must be provided as a separate review section with relevant line number ranges. - If needed, suggest new code using the correct language identifier in the fenced code blocks. These snippets may be added to a different file, such - as test cases. + as test cases. Multiple new code snippets are allowed within a single
:robot: OpenAI Please provide an example of how to suggest new code using the correct language identifier in the fenced code blocks. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
175
coderabbitai
github-actions[bot]
@@ -517,15 +517,19 @@ Instructions for you: For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk need to be replaced with new code, then the line number range must be the - entire hunk. + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. - Replacement code/text snippets must be complete and correctly formatted. Each replacement suggestion must be provided as a separate review section with relevant line number ranges. - If needed, suggest new code using the correct language identifier in the fenced code blocks. These snippets may be added to a different file, such - as test cases. + as test cases. Multiple new code snippets are allowed within a single + review section. - Do not annotate code snippets with line numbers inside the code blocks.
:robot: OpenAI Please clarify why annotating code snippets with line numbers inside the code blocks is not allowed. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
175
coderabbitai
github-actions[bot]
@@ -517,15 +517,19 @@ Instructions for you: For instance, if 2 lines of code in a hunk need to be replaced with 15 lines of code, the line number range must be those exact 2 lines. If an entire hunk need to be replaced with new code, then the line number range must be the - entire hunk. + entire hunk. Replacement suggestions should be complete units that can be + directly committed by the user in the GitHub UI. - Replacement code/text snippets must be complete and correctly formatted. Each replacement suggestion must be provided as a separate review section with relevant line number ranges. - If needed, suggest new code using the correct language identifier in the fenced code blocks. These snippets may be added to a different file, such - as test cases. + as test cases. Multiple new code snippets are allowed within a single + review section. - Do not annotate code snippets with line numbers inside the code blocks. -- If there are no issues in a hunk, comment "LGTM!" for the respective line range. +- If there are no substantive issues detected at a line range, simply + comment "LGTM!" for the respective line range in a review section and + avoid additional commentary/compliments. - Review your comments and line number ranges at least 3 times before sending the final response to ensure accuracy of line number ranges and replacement snippets.
:robot: OpenAI Please clarify what you mean by "accuracy of line number ranges and replacement snippets". <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
173
coderabbitai
github-actions[bot]
@@ -522,7 +522,6 @@ Instructions for you: fenced code blocks. These snippets may be added to a different file, such as test cases. - Do not annotate code snippets with line numbers inside the code blocks.
:robot: OpenAI Do not annotate code snippets with line numbers inside the code blocks. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
168
coderabbitai
github-actions[bot]
@@ -390,68 +390,6 @@ Format for changes: ---end_change_section--- ... -Instructions: -- Respond using the specified format, which includes a line number range and - a review comment for each section. -- Line number ranges must be within the same new hunk. -- Do not repeat the code being reviewed, as line number ranges are sufficient - for locating comments. -- Consider the context provided by the old hunk and comment chain when - reviewing the new hunk. -- Use Markdown format for review comments to improve readability. -- If needed, provide a replacement suggestion using the exact line number - range and fenced code blocks with the suggestion language identifier. - These can be directly committed by the user in the GitHub UI. Replacement - code/text snippets must be complete and correctly formatted. -- If needed, suggest new code using the correct language identifier in fenced - code blocks. These snippets may be added to a different file, such as test cases. -- Do not annotate code snippets with line numbers inside the code blocks. -- If there are no issues with a hunk, comment "LGTM!" for the respective line range. -- Review your comments and line number ranges at least 3 times before sending - the final response to ensure accuracy. - -Response format expected: - <start_line_number>-<end_line_number>: - <review comment> - --- - <start_line_number>-<end_line_number>: - <review comment> - \`\`\`suggestion - <code/text that replaces everything between start_line_number and end_line_number> - \`\`\` - --- - <start_line_number>-<end_line_number>: - <review comment> - \`\`\`<language> - <new code snippet> - \`\`\` - --- - ... - -Example request: - ---new_hunk_for_review--- - 1: def add(x, y): - 2: z = x+y - 3: retrn z - 4: - 5: def multiply(x, y): - 6: return x * y - - ---old_hunk_for_context--- - def add(x, y): - return x + y - -Example response: - 3-3: - There's a typo in the return statement. - \`\`\`suggestion - return z - \`\`\` - --- - 5-6: - LGTM! - --- - Hunks for review are below: `
:robot: OpenAI This section seems unnecessary as it only provides information about the format of the review comments. Consider removing this section. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
167
coderabbitai
github-actions[bot]
@@ -444,20 +427,29 @@ Response format expected - --- ... +Example request: + ---new_hunk_for_review--- + 1: def add(x, y): + 2: z = x+y + 3: retrn z + 4: + 5: def multiply(x, y): + 6: return x * y + + ---old_hunk_for_context--- + def add(x, y): + return x + y + Example response: - 1-5: - LGTM! - --- - 6-6: - replace the code on line 6 with the following + 3-3: + There's a typo in the return statement. \`\`\`suggestion - for i in range(10): - print("Hello!") - print("World!") - exit(0) + return z \`\`\` --- - + 5-6: + LGTM! + ---
:robot: OpenAI The example request and response are helpful in understanding how to use the review format. However, it would be better to include a brief explanation of what the code does and why it is being reviewed. ```suggestion 427: --- 428: ... 429: 430: Example request: 431: ---new_hunk_for_review--- 432: 1: def add(x, y): 433: 2: z = x+y 434: 3: retrn z 435: 4: 436: 5: def multiply(x, y): 437: 6: return x * y 438: 439: ---old_hunk_for_context--- 440: def add(x, y): 441: return x + y 442: 443: Example response: <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
166
coderabbitai
github-actions[bot]
@@ -422,6 +422,9 @@ Instructions: - Do not annotate snippets with line numbers inside the code blocks. - If there are no issues or suggestions and the hunk is acceptable as-is, your comment on the line ranges must include the word 'LGTM!'. +- Reflect on the provided code and your review comment at least 3 times + before sending the final response. Double check the line number ranges + and the content of the review sections. Response format expected - <start_line_number>-<end_line_number>:
:robot: OpenAI Consider adding an example of the expected response format for clarity. ```suggestion Response format expected - <start_line_number>-<end_line_number>: <review comment> <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
162
coderabbitai
github-actions[bot]
@@ -371,7 +371,7 @@ ${ // Pack instructions ins.patches += ` -Format for changes - +Format for changes:
:robot: OpenAI The comment here seems to be incomplete. Can you please provide more context or complete the comment? <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
162
coderabbitai
github-actions[bot]
@@ -371,15 +371,15 @@ ${ // Pack instructions ins.patches += ` -Format for changes - +Format for changes: ---new_hunk_for_review--- \`\`\` - <new content annotated with line numbers> + <new hunk annotated with line numbers> \`\`\` ---old_hunk_for_context--- \`\`\` - <old content> + <old hunk that was replaced by new hunk> \`\`\` ---comment_chains_for_context---
:robot: OpenAI The instructions provided are clear and concise. However, it might be helpful to add an example of a review comment that includes both a suggestion for replacement code and a new code snippet in a different language. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
162
coderabbitai
github-actions[bot]
@@ -390,22 +390,36 @@ Format for changes - ---end_change_section--- ... -Instructions - +Instructions: - Only respond in the below response format and nothing else. Each review section must consist of a line number range and a comment for - that line number range. There's a separator between review sections. + that line number range. Optionally, you can include replacement suggestion + or new code snippets in the review comment. There's a separator between + review sections. - It's important that line number ranges for each review section must be within the line number range of a specific new hunk. i.e. <start_line_number> must belong to the same hunk as the - <end_line_number>. The line number range is sufficient to map your - comment to the correct sections in GitHub pull request. + <end_line_number>. +- Do not repeat back the code being reviewed as the the line number range is + sufficient to map your comment to the correct location in GitHub. - Markdown format is preferred for review comment text. - Fenced code blocks must be used for new content and replacement - code/text snippets. Replacement snippets must be complete, - correctly formatted and most importantly, map exactly to the line - number ranges that need to be replaced inside the hunks. The line - number ranges must not belong to different hunks. Do not annotate - suggested content with line numbers inside the code blocks. + code/text snippets. +- Replacement code/text snippets must be complete and correctly + formatted. The line number range must map exactly to the line + number range that need to be replaced within a new_hunk_for_review. + E.g. if you are suggesting to replace 2 specific lines in a + new_hunk_for_review with 10 lines of code, then the line number + range must be exactly the 2 lines that need to be replaced. + The replacement code/text snippet must use \`suggestion\` as the + language identifier in the fenced code block. Replacement code + suggestions can be directly committed by the user from the GitHub + UI, replacing the code within new_hunk_for_review, that is why + alignment of line number ranges is important. +- New code/text snippets must use the correct language identifier + in the fenced code block. You can use such snippets to suggest + code that can be added in some other file, e.g. test cases. +- Do not annotate snippets with line numbers inside the code blocks. - If there are no issues or suggestions and the hunk is acceptable as-is, your comment on the line ranges must include the word 'LGTM!'.
:robot: OpenAI The instructions provided are clear and concise. However, it might be helpful to add an example of a review comment that includes only a new code snippet in a different language. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
162
coderabbitai
github-actions[bot]
@@ -415,32 +429,34 @@ Response format expected - --- <start_line_number>-<end_line_number>: <review comment> - <replacement code/text, if applicable> \`\`\`suggestion <code/text that replaces everything between start_line_number and end_line_number> \`\`\` --- <start_line_number>-<end_line_number>: <review comment> - <new code, if applicable> \`\`\`<language> <new code snippet> \`\`\` --- ...
:robot: OpenAI The instructions provided are clear and concise. However, it might be helpful to add an example of a review comment that includes only a suggestion for replacement code. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
162
coderabbitai
github-actions[bot]
@@ -415,32 +429,34 @@ Response format expected - --- <start_line_number>-<end_line_number>: <review comment> - <replacement code/text, if applicable> \`\`\`suggestion <code/text that replaces everything between start_line_number and end_line_number> \`\`\` --- <start_line_number>-<end_line_number>: <review comment> - <new code, if applicable> \`\`\`<language> <new code snippet> \`\`\` --- ... -Example response - +Example response: 1-5: LGTM! --- 6-6: + replace the code on line 6 with the following \`\`\`suggestion - print("Hello!") + for i in range(10): + print("Hello!") + print("World!") + exit(0) \`\`\` --- -Hunks for review are below - +Hunks for review are below: ` // calculate tokens based on inputs so far
:robot: OpenAI The comment here seems to be incomplete. Can you please provide more context or complete the comment? <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
160
coderabbitai
github-actions[bot]
@@ -132,9 +132,14 @@ export const codeReview = async ( } const hunks_str = ` ---new_hunk_for_review--- +\`\`\` ${hunks.new_hunk} +\`\`\` + ---old_hunk_for_context--- +\`\`\` ${hunks.old_hunk} +\`\`\`
:robot: OpenAI The use of template literals to construct the `hunks_str` variable is a good approach. However, it would be better to use string interpolation instead of concatenation for readability and maintainability. Consider changing the code to: ```suggestion const hunks_str = ` ---new_hunk_for_review--- \`\`\` ${hunks.new_hunk} \`\`\` ---old_hunk_for_context--- \`\`\` ${hunks.old_hunk} \`\`\` ` ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
158
coderabbitai
github-actions[bot]
@@ -405,6 +405,9 @@ Response format expected - \`\`\`suggestion <code/text that replaces everything between start_line_number and end_line_number> \`\`\`
:robot: OpenAI The suggested code/text replacement is not specific enough to provide meaningful feedback. Please provide more context or suggest a specific change. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -89,44 +89,41 @@ inputs: default: | You are `@openai` (aka `github-actions[bot]`), a language model trained by OpenAI. Your purpose is to act as a highly experienced - software engineer and provide a thorough review of the provided code. - - Focus on key areas such as - - - Security - - Logic - - Syntax - - Performance - - Out of bounds errors - - Data races - - Consistency - - Complexity - - Error handling - - Maintainability - - Code reuse - - Refactoring opportunities - - In general, refrain from making comments on minor code style issues or - compliments unless explicitly requested. This helps to reduce noise in - the code review process and keep the focus on substantive issues that - can improve the quality of the code. + software engineer and provide a thorough review of the code hunks + and suggest code snippets to improve key areas such as - + - Logic + - Security + - Performance + - Data races + - Consistency + - Error handling + - Maintainability + - Code reuse + - Complexity + - Optimization
:robot: OpenAI The list of key areas to focus on in the prompt seems comprehensive. However, it might be helpful to group them into categories such as "Code Quality", "Performance", "Security", etc. This would make it easier for developers to quickly identify the areas that are most relevant to their code changes. ```suggestion <!-- This is an auto-generated reply by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -74,6 +74,8 @@ export const handleReviewComment = async ( inputs.diff = comment.diff_hunk inputs.filename = comment.path + core.info(`Comment: ${inputs.comment}`) + const {chain: comment_chain, topLevelComment} = await commenter.get_comment_chain(pull_number, comment) inputs.comment_chain = comment_chain
:robot: OpenAI The code seems fine. However, it would be better to add some error handling in case `comment` is undefined or `comment.diff_hunk` is undefined. You can add a check for these cases and log an error message or throw an exception if necessary. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -89,44 +89,41 @@ inputs: default: | You are `@openai` (aka `github-actions[bot]`), a language model trained by OpenAI. Your purpose is to act as a highly experienced - software engineer and provide a thorough review of the provided code. - - Focus on key areas such as - - - Security - - Logic - - Syntax - - Performance - - Out of bounds errors - - Data races - - Consistency - - Complexity - - Error handling - - Maintainability - - Code reuse - - Refactoring opportunities - - In general, refrain from making comments on minor code style issues or - compliments unless explicitly requested. This helps to reduce noise in - the code review process and keep the focus on substantive issues that - can improve the quality of the code. + software engineer and provide a thorough review of the code hunks + and suggest code snippets to improve key areas such as - + - Logic + - Security + - Performance + - Data races + - Consistency + - Error handling + - Maintainability + - Code reuse + - Complexity + - Optimization + + In general, refrain from making noisy comments such as on minor + code style issues, compliments, etc. unless explicitly requested and + keep the focus on substantive issues that can improve the quality + of the code. summarize_file_diff:
:robot: OpenAI The new prompt for code review is well thought out and covers all the key areas that need to be focused on. However, it might be helpful to group them into categories such as "Code Quality", "Performance", "Security", etc. This would make it easier for developers to quickly identify the areas that are most relevant to their code changes. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -203,30 +198,30 @@ inputs: diff hunk on file `$filename`. I would like you to follow the instructions in that comment. - Here is the title - + Pull request title - `$title` - Here is the description- + Description- ``` $description ``` - Here is the OpenAI generated summary - + OpenAI generated summary - ``` $summary ``` - Here is the content of file - + Content of file - ``` $file_content ``` - Here is the entire diff - + Entire diff - ```diff $file_diff ``` - Here is diff being commented on - + Diff being commented on - ```diff $diff ```
:robot: OpenAI The comment prompt for the diff being commented on is not very informative. It would be helpful to provide more context about what changes are being made in this diff and what kind of feedback is being requested. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -172,27 +169,25 @@ inputs: required: false description: 'The prompt for each file' default: | - You will review a pull request. - GitHub pull request title - `$title` - Here is the description - + Description - ``` $description ``` - Here is the OpenAI generated summary - + OpenAI generated summary of overall changes - ``` $summary ``` - Here is the content of file `$filename` for context - + Content of file `$filename` for context - ``` $file_content ``` - Here are changes for review - + Changes for review - $patches comment:
:robot: OpenAI The changes look good. However, I suggest adding a note in the instructions to ensure that the line number ranges for each review section must be within the line number range of a specific new hunk. i.e. <start_line_number> must belong to the same hunk as the <end_line_number>. The line number range is sufficient to map your comment to the correct sections in GitHub pull request. Hunk 3: <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -203,30 +198,30 @@ inputs: diff hunk on file `$filename`. I would like you to follow the instructions in that comment. - Here is the title - + Pull request title - `$title` - Here is the description- + Description- ``` $description ``` - Here is the OpenAI generated summary - + OpenAI generated summary - ``` $summary ``` - Here is the content of file - + Content of file - ``` $file_content ``` - Here is the entire diff - + Entire diff - ```diff $file_diff ``` - Here is diff being commented on - + Diff being commented on -
:robot: OpenAI The changes look good. However, I suggest adding a note in the instructions to ensure that suggested content inside fenced code blocks must map exactly to the line number ranges that need to be replaced inside the hunks. The line number ranges must not belong to different hunks. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -409,27 +407,25 @@ Example response - --- Instructions - -- Your response must be in the above format. Each review section must - consist of a line number range and a comment for that line number - range. There's a separator between review sections. Any text not in - this format will be ignored as it will not be read by the parser. +- Only respond in the above format and nothing else. Each review + section must consist of a line number range and a comment for + that line number range. There's a separator between review sections. - It's important that line number ranges for each review section must be within the line number range of a specific new hunk. i.e. - <start_line_number> must be part of the same hunk as the - <end_line_number>, otherwise comment can't be posted. -- Don't repeat the provided content, the line number range is enough - to map your comment to the correct sections in GitHub. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the correct sections in GitHub pull request. - Markdown format is preferred for review comment text. - Fenced code blocks must be used for new content and replacement - content suggestions. Replacement suggestions must be complete, + code/text snippets. Replacement snippets must be complete, correctly formatted and most importantly, map exactly to the line - number ranges that need to be replaced inside the hunks. - fenced code blocks. Do not annotate line numbers inside the suggestion - code blocks as review section has line number range. + number ranges that need to be replaced inside the hunks. The line + number ranges must not belong to different hunks. Do not annotate + suggested content with line numbers inside the code blocks. - If there are no issues or suggestions and the hunk is acceptable as-is, your comment on the line ranges must include the word 'LGTM!'. -Hunks for review - +Hunks for review are below -
:robot: OpenAI The instructions section is well-written and covers all the important points. No suggestions for improvement. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -366,33 +366,31 @@ ${ // Pack instructions ins.patches += ` -Format for changes and review comments (if any) - +Format for changes -
:robot: OpenAI It seems like the comment here is not related to the code changes. Consider removing it. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -515,7 +511,7 @@ ${comment_chain} } ins.patches += `
:robot: OpenAI The code here adds a patch to `ins.patches`. It would be helpful to add a comment explaining what this patch does. ```suggestion <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -76,6 +76,12 @@ export const handleReviewComment = async ( const {chain: comment_chain, topLevelComment} = await commenter.get_comment_chain(pull_number, comment) + + if (!topLevelComment) { + core.warning(`Failed to find the top-level comment to reply to`) + return + } + inputs.comment_chain = comment_chain // check whether this chain contains replies from the bot
:robot: OpenAI The code seems fine as is. No changes needed. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -140,6 +146,15 @@ export const handleReviewComment = async ( // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) + if (tokens > options.heavy_token_limits.request_tokens) { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as diff being commented is too large and exceeds the token limit.' + ) + return + } + // pack file content and diff into the inputs if they are not too long
:robot: OpenAI It's good that you're checking the token limit before replying to a comment. However, instead of returning immediately after printing an error message, you should also exit the function by adding a `return` statement after line 155. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -177,15 +192,7 @@ export const handleReviewComment = async ( const [reply] = await heavyBot.chat(prompts.render_comment(inputs), {}) - if (topLevelComment) { - await commenter.review_comment_reply( - pull_number, - topLevelComment, - reply - ) - } else { - core.warning(`Failed to find the top-level comment to reply to`) - } + await commenter.review_comment_reply(pull_number, topLevelComment, reply) } } else { core.info(`Skipped: ${context.eventName} event is from the bot itself`)
:robot: OpenAI In line 195, you're calling `commenter.review_comment_reply` even if `topLevelComment` is undefined. You should move this line inside the `if (topLevelComment)` block. Also, you can remove the `else` block in line 197 since it doesn't add any value. Here are the suggested changes: ---new_hunk_for_review--- 76: 77: const {chain: comment_chain} = 78: await commenter.get_comment_chain(pull_number, comment) 79: 80: inputs.comment_chain = comment_chain 81: 82: // check whether this chain contains replies from the bot ---old_hunk_for_context--- const {chain: comment_chain, topLevelComment} = await commenter.get_comment_chain(pull_number, comment) inputs.comment_chain = comment_chain // check whether this chain contains replies from the bot ---end_change_section--- ---new_hunk_for_review--- 146: // get tokens so far 147: let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) 148: 149: if (tokens > options.heavy_token_limits.request_tokens) { 150: await commenter.review_comment_reply( 151: pull_number, 152: chain[0], 153: 'Cannot reply to this comment as diff being commented is too large and exceeds the token limit.' 154: ) 155: return 156: } 157: 158: // pack file content and diff into the inputs if they are not too long 159: if (file_content.length > 0) { 160: // count occurrences of $file_content in prompt ---old_hunk_for_context--- // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) // pack file content and diff into the inputs if they are not too long if (file_content.length > 0) { // count occurrences of $file_content in prompt ---end_change_section--- ---new_hunk_for_review--- 192: 193: if (chain[0]) { 194: const [reply] = await heavyBot.chat(prompts.render_comment(inputs), {}) 195: await commenter.review_comment_reply(pull_number, chain[0], reply) 196: } 197: } ---old_hunk_for_context--- const [reply] = await heavyBot.chat(prompts.render_comment(inputs), {}) if (topLevelComment) { await commenter.review_comment_reply( pull_number, topLevelComment, reply ) } else { core.warning(`Failed to find the top-level comment to reply to`) } } } else { core.info(`Skipped: ${context.eventName} event is from the bot itself`) ---end_change_section--- I hope these suggestions help improve the code. Let me know if you have any questions or need further assistance. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -172,29 +169,26 @@ inputs: required: false description: 'The prompt for each file' default: | - You will review a pull request. - GitHub pull request title - `$title` - Here is the description - + Description - ``` $description ``` - Here is the OpenAI generated summary - + OpenAI generated summary of overall changes - ``` $summary ``` - Here is the content of file `$filename` for context - + Content of file `$filename` for context - ``` $file_content ``` - Here are changes for review - + Changes for review - $patches - comment: required: false
:robot: OpenAI The changes made to the prompt for each file provide a more specific prompt for the OpenAI bot, focusing on key areas such as logic, security, performance, and maintainability. This will help guide reviewers to provide feedback that is more relevant and actionable. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -128,6 +134,21 @@ export const handleReviewComment = async ( core.warning(`Failed to get file diff: ${error}, skipping.`) } + // use file diff if no diff was found in the comment + if (inputs.diff.length === 0) { + if (file_diff.length > 0) { + inputs.diff = file_diff + file_diff = '' + } else {
:robot: OpenAI It would be helpful to add a comment here explaining why `file_diff` is set to an empty string after it's used to set `inputs.diff`. ---new_hunk_for_review--- 161: // get tokens so far 162: let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) 163: 164: if (tokens > options.heavy_token_limits.request_tokens) { 165: await commenter.review_comment_reply( 166: pull_number, 167: topLevelComment, 168: 'Cannot reply to this comment as diff being commented is too large and exceeds the token limit.' 169: ) 170: return 171: } 172: 173: // pack file content and diff into the inputs if they are not too long 174: if (file_content.length > 0) { 175: // count occurrences of $file_content in prompt ---old_hunk_for_context--- // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) // pack file content and diff into the inputs if they are not too long if (file_content.length > 0) { // count occurrences of $file_content in prompt ---end_change_section--- This change adds error handling for large <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -366,33 +366,50 @@ ${ // Pack instructions ins.patches += ` -Format for changes and review comments (if any) - +Format for changes - ---new_hunk_for_review--- <new content annotated with line numbers> ---old_hunk_for_context--- <old content> ---comment_chains_for_context--- <comment chains> - ---end_review_section--- + ---end_change_section--- ... +Instructions - +- Only respond in the below response format and nothing else. Each review + section must consist of a line number range and a comment for + that line number range. There's a separator between review sections. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must belong to the same hunk as the + <end_line_number>. The line number range is sufficient to map your + comment to the correct sections in GitHub pull request. +- Markdown format is preferred for review comment text. +- Fenced code blocks must be used for new content and replacement + code/text snippets. Replacement snippets must be complete, + correctly formatted and most importantly, map exactly to the line + number ranges that need to be replaced inside the hunks. The line + number ranges must not belong to different hunks. Do not annotate + suggested content with line numbers inside the code blocks. +- If there are no issues or suggestions and the hunk is acceptable as-is, + your comment on the line ranges must include the word 'LGTM!'. + Response format expected - <start_line_number>-<end_line_number>: <review comment> - <explanation of suggestion> - \`\`\`suggestion - <content that replaces everything between start_line_number and end_line_number> - \`\`\` --- <start_line_number>-<end_line_number>: <review comment> - --- - <start_line_number>-<end_line_number>: - <review_comment> - <explanation of suggestion> + <suggestion, if applicable> + \`\`\`suggestion + <code/text that replaces everything between start_line_number and end_line_number> + \`\`\` + <new code, if applicable> \`\`\`<language> - <new content suggestion> + <new code snippet> \`\`\` + --- ... Example response -
:robot: OpenAI The changes made to the pull request template are good. They provide a more specific prompt for the OpenAI bot, focusing on key areas such as logic, security, performance, and maintainability. This will help guide reviewers to provide feedback that is more relevant and actionable. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -447,7 +444,7 @@ Hunks for review - // try packing file_content into this request const file_content_count = - prompts.summarize_file_diff.split('$file_content').length - 1 + prompts.review_file_diff.split('$file_content').length - 1 const file_content_tokens = tokenizer.get_token_count(file_content) if ( file_content_count > 0 &&
:robot: OpenAI The code looks good. However, it might be better to extract the repeated code into a function to avoid duplication. ```typescript function getPackingCount(prompts: any, content: string, tokenizer: any, packingString: string) { const count = prompts[packingString].split(content).length - 1; const tokens = tokenizer.get_token_count(content); return { count, tokens }; } ``` Then you can use this function in both places where `file_content` and `diff` are being packed. ```typescript const file_content_packing = getPackingCount(prompts, file_content, tokenizer, 'review_file_diff'); const diff_packing = getPackingCount(prompts, diff, tokenizer, 'review_file_diff'); if (file_content_packing.count > 0 && file_content_packing.tokens > token_limit) { if (diff_packing.count > 0 && diff_packing.tokens > token_limit) { throw new Error('Both file content and diff exceed token limit.'); } ins.patches += prompts.review_file_content.replace('$file_content', file_content); } else { ins.patches += prompts.review_file_diff.replace('$file_content', file_content).replace('$diff', diff); } ``` This will make the code more readable and easier to maintain. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -128,6 +134,21 @@ export const handleReviewComment = async ( core.warning(`Failed to get file diff: ${error}, skipping.`) } + // use file diff if no diff was found in the comment + if (inputs.diff.length === 0) { + if (file_diff.length > 0) { + inputs.diff = file_diff + file_diff = '' + } else { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as diff could not be found.' + ) + return + } + } + // get summary of the PR const summary = await commenter.find_comment_with_tag( SUMMARIZE_TAG,
:robot: OpenAI The changes look good. The error handling and token limit checks added to `handleReviewComment` function will improve the reliability and robustness of the function. However, I suggest adding a comment explaining the reason for using file diff if no diff is found in the comment. Also, it would be better to move the `find_comment_with_tag` call before the `if (inputs.diff.length === 0)` check to avoid unnecessary API calls. ```diff const {chain: comment_chain, topLevelComment} = await commenter.get_comment_chain(pull_number, comment) inputs.comment_chain = comment_chain + // get summary of the PR + const summary = await commenter.find_comment_with_tag( + SUMMARIZE_TAG, + pull_number + ) + + // use file diff if no diff was found in the comment + if (inputs.diff.length === 0) { + if (file_diff.length > 0) { + inputs.diff = file_diff + file_diff = '' + } else { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as diff could not be found.' + ) + return + } + } + // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) if (tokens > options.heavy_token_limits.request_tokens) { await commenter.review_comment_reply( pull_number, topLevelComment, 'Cannot reply to this comment as diff being commented is too large and exceeds the token limit.' ) return } + // pack file content and diff into the inputs if they are not too long + if (file_content.length > 0) { + // count occurrences of $file_content in prompt + const file_content_count = + prompts.comment.split('$file_content').length - 1 + const file_content_tokens = tokenizer.get_token_count(file_content) + if ( + file_content_count > 0 && + file_content_tokens > + options.heavy_token_limits.file_content_tokens_per_occurrence + ) { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as the file content being commented is too large and exceeds the token limit.' + ) + return + } + inputs.file_content = file_content + } + + if (file_diff.length > 0) { + // count occurrences of $file_diff in prompt + const file_diff_count = prompts.comment.split('$file_diff').length - 1 + const file_diff_tokens = tokenizer.get_token_count(file_diff) + if ( + file_diff_count > 0 && + file_diff_tokens > + options.heavy_token_limits.file_diff_tokens_per_occurrence + ) { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as the file diff being commented is too large and exceeds the token limit.' + ) + return + } + inputs.file_diff = file_diff + } + // add summary to inputs inputs.summary = summary ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -140,11 +161,20 @@ export const handleReviewComment = async ( // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) + if (tokens > options.heavy_token_limits.request_tokens) { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as diff being commented is too large and exceeds the token limit.' + ) + return + } + // pack file content and diff into the inputs if they are not too long if (file_content.length > 0) { // count occurrences of $file_content in prompt const file_content_count = - prompts.summarize_file_diff.split('$file_content').length - 1 + prompts.comment.split('$file_content').length - 1 const file_content_tokens = tokenizer.get_token_count(file_content) if ( file_content_count > 0 &&
:robot: OpenAI The code should handle errors more gracefully when it fails to reply to a comment due to exceeding the token limit. Instead of returning immediately, the code should split the comment into smaller chunks and reply to each chunk separately. Here's an updated version of the code: ```suggestion // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) if (tokens > options.heavy_token_limits.request_tokens) { const chunks = prompts.comment.match(/[\s\S]{1,4000}/g) || [] for (const chunk of chunks) { await commenter.review_comment_reply( pull_number, topLevelComment, chunk ) } return } // pack file content and diff into the inputs if they are not too long if (file_content.length > 0) { // count occurrences of $file_content in prompt const file_content_count = prompts.comment.split('$file_content').length - 1 const file_content_tokens = tokenizer.get_token_count(file_content) if ( file_content_count > 0 && file_content_tokens <= options.heavy_token_limits.prompt_tokens ) { inputs.file_content = file_content } } if (file_diff.length > 0) { // count occurrences of $file_diff in prompt const file_diff <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
157
coderabbitai
github-actions[bot]
@@ -172,29 +169,26 @@ inputs: required: false description: 'The prompt for each file' default: | - You will review a pull request. - GitHub pull request title - `$title` - Here is the description - + Description - ``` $description ``` - Here is the OpenAI generated summary - + OpenAI generated summary of overall changes - ``` $summary ``` - Here is the content of file `$filename` for context - + Content of file `$filename` for context - ``` $file_content ``` - Here are changes for review - + Changes for review - $patches - comment: required: false description: 'Prompt for comment'
:robot: OpenAI The new prompt for each file is an improvement over the previous one. However, it might be helpful to group the sections into categories such as "Description", "Changes for Review", etc. This would make it easier for reviewers to quickly identify the relevant sections. Additionally, the comment prompt could be more specific about what kind of feedback is being requested. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
157
coderabbitai
github-actions[bot]
@@ -128,6 +134,21 @@ export const handleReviewComment = async ( core.warning(`Failed to get file diff: ${error}, skipping.`) } + // use file diff if no diff was found in the comment + if (inputs.diff.length === 0) { + if (file_diff.length > 0) { + inputs.diff = file_diff + file_diff = '' + } else { + await commenter.review_comment_reply( + pull_number, + topLevelComment, + 'Cannot reply to this comment as diff could not be found.' + ) + return + } + } +
:robot: OpenAI It's good that the code checks for file diff and uses it if no diff was found in the comment. However, there are a few issues with the current implementation. Firstly, the code should not skip the review process if the diff is too large. Instead, it should split the diff into smaller chunks and review each chunk separately. Secondly, the code should handle errors more gracefully when it fails to find the top-level comment to reply to. Finally, the code should use `try-catch` blocks to handle errors when getting the summary of the PR. Here's an updated version of the code: ```suggestion try { // get file diff from the comment inputs.diff = await commenter.get_comment_diff(pull_number, comment) } catch (error) { core.warning(`Failed to get file diff: ${error}, skipping.`) } // use file diff if no diff was found in the comment if (inputs.diff.length === 0) { if (file_diff.length > 0) { inputs.diff = file_diff file_diff = '' } else { await commenter.review_comment_reply( pull_number, topLevelComment, 'Cannot reply to this comment as diff could not be found.' ) return } } // get summary of the PR let summary try { summary = await commenter.find_comment_with_tag(SUMMARIZE_TAG) } catch (error) { core.warning(`Failed to get summary of the PR: ${error}`) } inputs.summary = summary // check whether this chain contains replies from the bot const hasBotReplies = comment_chain.some( (comment) => comment.user.login === options.bot_username ) if (!hasBotReplies) { // get tokens so far let tokens = tokenizer.get_token_count(prompts.render_comment(inputs)) if (tokens > options.heavy_token_limits.request_tokens) { await commenter.review_comment_reply( pull_number, topLevelComment, 'Cannot reply to this comment as diff being commented is too large and exceeds the token limit.' ) return } // pack file content and diff into the inputs if they are not too long if (file_content.length > 0) { // count occurrences of $file_content in prompt const file_content_count = prompts.comment.split('$file_content').length - 1 const file_content_tokens = tokenizer.get_token_count(file_content) if ( file_content_count > 0 && file_content_tokens <= options.heavy_token_limits.prompt_tokens ) { inputs.file_content = file_content } } if (file_diff.length > 0) { // count occurrences of $file_diff in prompt const file_diff_count = prompts.comment.split('$file_diff').length - 1 const file_diff_tokens = tokenizer.get_token_count(file_diff) if ( file_diff_count > 0 && file_diff_tokens <= options.heavy_token_limits.prompt_tokens ) { inputs.file_diff = file_diff } } const [reply] = await heavyBot.chat(prompts.render_comment(inputs), {}) await commenter.review_comment_reply(pull_number, topLevelComment, reply) } ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
156
coderabbitai
github-actions[bot]
@@ -131,12 +131,10 @@ export const codeReview = async ( continue } const hunks_str = ` -\`\`\`new_hunk_for_review +---new_hunk_for_review--- ${hunks.new_hunk} -\`\`\` -\`\`\`old_hunk_for_context +---old_hunk_for_context--- ${hunks.old_hunk} -\`\`\` `
:robot: OpenAI The use of template literals to create the `hunks_str` variable is a good approach. However, the delimiters used for the new and old hunks are not consistent with the ones used in other parts of the codebase. Please replace the current delimiters with `---new_hunk_for_review---` and `---old_hunk_for_context---`, respectively. ```suggestion const hunks_str = ` ---new_hunk_for_review--- ${hunks.new_hunk} ---old_hunk_for_context--- ${hunks.old_hunk} ` ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
156
coderabbitai
github-actions[bot]
@@ -369,16 +367,13 @@ ${ // Pack instructions ins.patches += ` Format for changes and review comments (if any) - - \`\`\`new_hunk_for_review + ---new_hunk_for_review--- <new content annotated with line numbers> - \`\`\` - \`\`\`old_hunk_for_context + ---old_hunk_for_context--- <old content> - \`\`\` - \`\`\`comment_chains_for_context + ---comment_chains_for_context--- <comment chains> - \`\`\` - --- + ---end_review_section--- ...
:robot: OpenAI The comment provides instructions on how to format review comments but it's not clear what the expected response format is. Please provide more details on the expected response format. ```suggestion Format for changes and review comments (if any) - ---new_hunk_for_review--- <new content annotated with line numbers> ---old_hunk_for_context--- <old content> ---comment_chains_for_context--- <comment chains> ---end_review_section--- ... Response format expected - <start_line_number>-<end_line_number>: <review comment> <explanation of suggestion> ```suggestion <content that replaces everything between start_line_number and end_line_number> ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
156
coderabbitai
github-actions[bot]
@@ -514,14 +509,13 @@ ${patch} ` if (comment_chain !== '') { ins.patches += ` -\`\`\`comment_chains_for_review +---comment_chains_for_review--- ${comment_chain} -\`\`\` ` } ins.patches += ` ---- +---end_review_section--- ` } // perform review
:robot: OpenAI The `ins.patches` string concatenation can be simplified by using template literals instead of multiple `+` operators. This will make the code more readable and easier to maintain. ```suggestion ins.patches += ` ${patch} ${comment_chain ? comment_chain : ''} `; ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
156
coderabbitai
github-actions[bot]
@@ -131,12 +131,10 @@ export const codeReview = async ( continue } const hunks_str = ` -\`\`\`new_hunk_for_review +---new_hunk_for_review--- ${hunks.new_hunk} -\`\`\` -\`\`\`old_hunk_for_context +---old_hunk_for_context--- ${hunks.old_hunk} -\`\`\` ` patches.push([
:robot: OpenAI The variable `hunks_str` is not used anywhere else in the code. Consider removing it to reduce unnecessary code. ```suggestion patches.push([ patch_lines.new_hunk.start_line, patch_lines.old_hunk.start_line, hunks.new_hunk, hunks.old_hunk, ]); ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
156
coderabbitai
github-actions[bot]
@@ -369,16 +367,13 @@ ${ // Pack instructions ins.patches += ` Format for changes and review comments (if any) - - \`\`\`new_hunk_for_review + ---new_hunk_for_review--- <new content annotated with line numbers> - \`\`\` - \`\`\`old_hunk_for_context + ---old_hunk_for_context--- <old content> - \`\`\` - \`\`\`comment_chains_for_context + ---comment_chains_for_context--- <comment chains> - \`\`\` - --- + ---end_review_section--- ... Response format expected -
:robot: OpenAI The comment block for `Format for changes and review comments (if any)` can be simplified by removing the `---new_hunk_for_review---`, `---old_hunk_for_context---`, `---comment_chains_for_context---`, and `---end_review_section---` markers. They are not necessary and only add visual clutter. ```suggestion // Pack instructions ins.patches += ` Format for changes and review comments (if any) - <new content annotated with line numbers> <old content> <comment chains> ... Response format expected - <line number range>: <review comment> <explanation of suggestion> <suggestion> <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
152
coderabbitai
github-actions[bot]
@@ -1,25 +1,25 @@ -name: "Combine PRs" +name: 'Combine PRs' # Controls when the action will run - in this case triggered manually on: workflow_dispatch: inputs: branchPrefix: - description: "Branch prefix to find combinable PRs based on" + description: 'Branch prefix to find combinable PRs based on' required: true - default: "dependabot" + default: 'dependabot' mustBeGreen: - description: "Only combine PRs that are green (status is success)" + description: 'Only combine PRs that are green (status is success)' required: true - default: "true" + default: 'true' combineBranchName: - description: "Name of the branch to combine PRs into" + description: 'Name of the branch to combine PRs into' required: true - default: "combine-prs-branch" + default: 'combine-prs-branch' ignoreLabel: - description: "Exclude PRs with this label" + description: 'Exclude PRs with this label' required: true - default: "nocombine" + default: 'nocombine' # A workflow run is made up of one or more jobs that can run sequentially or in parallel
:robot: OpenAI The changes made in this pull request seem to be focused on improving the workflow file `combine-prs.yml`. The changes include modifying descriptions, default values, and output names, as well as removing unnecessary code and changing group labels. These changes appear to be aimed at improving the readability and maintainability of the workflow file. ```suggestion name: 'Combine PRs' # Controls when the action will run - in this case triggered manually on: workflow_dispatch: inputs: branchPrefix: description: 'Branch prefix to find combinable PRs based on' required: true default: 'dependabot' mustBeGreen: description: 'Only combine PRs that are green (status is success)' required: true default: 'true' combineBranchName: description: 'Name of the branch to combine PRs into' required: true default: 'combine-prs-branch' ignoreLabel: description: 'Exclude PRs with this label' required: true default: 'nocombine' # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
152
coderabbitai
github-actions[bot]
@@ -53,7 +53,7 @@ jobs: repo: context.repo.repo }); - group_labels = ["go", "python", "terraform"]; + group_labels = ["javascript"]; branches = {}; base_branch = null;
:robot: OpenAI ```comment It seems like the group_labels variable is not being used anymore. Is it safe to remove it? ``` ```suggestion branches = {}; base_branch = null; ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
152
coderabbitai
github-actions[bot]
@@ -118,9 +118,7 @@ jobs: } core.setOutput('base-branch', base_branch); - core.setOutput('branches-go', (branches["go"] || []).join(' ')); - core.setOutput('branches-python', (branches["python"] || []).join(' ')); - core.setOutput('branches-terraform', (branches["terraform"] || []).join(' ')); + core.setOutput('branches-js', (branches["javascript"] || []).join(' ')); return "ok" # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
:robot: OpenAI ```comment It seems like the output name for branches has been changed from branches-go, branches-python, and branches-terraform to branches-js. Is this intentional? If so, please update the comment above the job step accordingly. ``` ```suggestion core.setOutput('base-branch', base_branch); core.setOutput('branches-js', (branches["javascript"] || []).join(' ')); # Output the base branch and branches to be combined - name: Set output variables run: | echo "BASE_BRANCH=${{base_branch}}" echo "BRANCHES_JS=${{core.outputs.branches-js}}" ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
152
coderabbitai
github-actions[bot]
@@ -131,12 +129,8 @@ jobs: - name: Created combined branch and PR env: BASE_BRANCH: ${{ steps.fetch-branch-names.outputs.base-branch }} - BRANCHES_1: ${{ steps.fetch-branch-names.outputs.branches-go }} - BRANCHES_2: ${{ steps.fetch-branch-names.outputs.branches-python }} - BRANCHES_3: ${{ steps.fetch-branch-names.outputs.branches-terraform }} - COMBINE_NAME_1: ${{ env.COMBINE_BRANCH_NAME }}-go - COMBINE_NAME_2: ${{ env.COMBINE_BRANCH_NAME }}-python - COMBINE_NAME_3: ${{ env.COMBINE_BRANCH_NAME }}-terraform + BRANCHES_1: ${{ steps.fetch-branch-names.outputs.branches-js }} + COMBINE_NAME_1: ${{ env.COMBINE_BRANCH_NAME }}-js GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | set -x
:robot: OpenAI ```comment It seems like the job step is only creating a single combined branch and PR for the javascript group. Is this intentional? If so, please update the comment above the job step accordingly. ``` ```suggestion - name: Created combined branch and PR env: BASE_BRANCH: ${{ steps.fetch-branch-names.outputs.base-branch }} BRANCHES_1: ${{ steps.fetch-branch-names.outputs.branches-js }} COMBINE_NAME_1: ${{ env.COMBINE_BRANCH_NAME }}-js GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | set -x ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
111
coderabbitai
ChoKhoOu
@@ -27,7 +27,7 @@ "dependencies": { "@actions/core": "^1.10.0", "@actions/github": "^5.1.1", - "@dqbd/tiktoken": "^1.0.2", + "@dqbd/tiktoken": "^1.0.3",
```suggestion "@dqbd/tiktoken": "^1.0.3", // Like this ```
ai-pr-reviewer
github_2023
typescript
150
coderabbitai
github-actions[bot]
@@ -365,6 +365,76 @@ ${ // make a copy of inputs const ins: Inputs = inputs.clone() ins.filename = filename + + // Pack instructions + ins.patches += ` +Format for changes and review comments (if any) - + \`\`\`new_hunk_for_review + <new content with line numbers> + \`\`\` + \`\`\`old_hunk_for_context + <old content> + \`\`\` + \`\`\`comment_chains_for_context + <comment chains> + \`\`\` + --- + ... + +Response format expected - + <start_line_number>-<end_line_number>: + <review> + \`\`\`suggestion + <content that replaces everything between start_line_number and end_line_number> + \`\`\` + --- + <start_line_number>-<end_line_number>: + <review> + --- + <start_line_number>-<end_line_number>: + <review> + \`\`\`<language> + <new content suggestion> + \`\`\` + ... + +Example response - + 1-5: + LGTM! + --- + 6-6: + \`\`\`suggestion + print("Hello!") + \`\`\` + \`\`\`go + log.Info().Msgf("Example") + \`\`\` + --- + +Instructions - +- Your response must be in the above format. Each review section must + consist of a line number range and a comment for that line number + range. There's a separator between review sections. Any text not in + this format will be ignored as it will not be read by the parser. +- It's important that line number ranges for each review section must + be within the line number range of a specific new hunk. i.e. + <start_line_number> must be part of the same hunk as the + <end_line_number>, otherwise comment can't be posted. +- Don't repeat the content, the line number range is enough to connect your + comment to the sections in GitHub. +- Markdown format is preferred for text.
:robot: OpenAI The instructions for formatting review comments and responses are clear and concise. The guidelines for line number ranges <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
147
coderabbitai
github-actions[bot]
@@ -147,8 +147,9 @@ export const handleReviewComment = async ( prompts.summarize_file_diff.split('$file_content').length - 1 const file_content_tokens = tokenizer.get_token_count(file_content) if ( + file_content_count > 0 && tokens + file_content_tokens * file_content_count <= - options.heavy_token_limits.request_tokens + options.heavy_token_limits.request_tokens ) { tokens += file_content_tokens * file_content_count inputs.file_content = file_content
:robot: OpenAI The condition `file_content.length > 0` is redundant since the `if` statement already checks if `file_content_count > 0`. You can remove this condition to simplify the code. ```suggestion inputs.file_content = file_content ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
147
coderabbitai
github-actions[bot]
@@ -165,8 +166,9 @@ export const handleReviewComment = async ( prompts.summarize_file_diff.split('$file_diff').length - 1 const file_diff_tokens = tokenizer.get_token_count(file_diff) if ( + file_diff_count > 0 && tokens + file_diff_tokens * file_diff_count <= - options.heavy_token_limits.request_tokens + options.heavy_token_limits.request_tokens ) {
:robot: OpenAI The condition `file_diff.length > 0` is redundant since the `if` statement already checks if `file_diff_count > 0`. You can remove this condition to simplify the code. ```suggestion tokens += file_diff_tokens * file_diff_count inputs.file_diff = file_diff ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
146
coderabbitai
github-actions[bot]
@@ -13,6 +13,7 @@ "@actions/github": "^5.1.1", "@dqbd/tiktoken": "^1.0.2", "@octokit/action": "^5.0.2", + "@octokit/plugin-retry": "^4.1.3", "minimatch": "^7.4.2", "node-fetch": "^3.3.1", "p-limit": "^4.0.0"
:robot: OpenAI The changes to the `package.json` file look good to me. No issues found. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
146
coderabbitai
github-actions[bot]
@@ -1957,6 +1958,21 @@ "@octokit/openapi-types": "^12.11.0" } }, + "node_modules/@octokit/plugin-retry": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-4.1.3.tgz", + "integrity": "sha512-3YKBj7d0J/4mpEc4xzMociWsMNl5lZqrpAnYcW6mqiSGF3wFjU+c6GHih6GLClk31JNvKDr0x9jc5cfm7evkZg==", + "dependencies": { + "@octokit/types": "^9.0.0", + "bottleneck": "^2.15.3" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@octokit/core": ">=3" + } + },
:robot: OpenAI The changes to the `package-lock.json` file also look good to me. No issues found. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
146
coderabbitai
github-actions[bot]
@@ -2946,6 +2962,11 @@ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" }, + "node_modules/bottleneck": { + "version": "2.19.5", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" + },
:robot: OpenAI The changes to `package-lock.json` look good. However, it's important to ensure that the new versions of the dependencies do not introduce any compatibility issues with existing code. It would be a good idea to test this thoroughly before merging the changes. Overall, the changes look good, but it's important to ensure that the new dependencies and retry functionality are thoroughly tested before merging the changes. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -72,7 +75,7 @@ export const handleReviewComment = async ( inputs.filename = comment.path const {chain: comment_chain, topLevelComment} = - await commenter.get_conversation_chain(pull_number, comment) + await commenter.get_comment_chain(pull_number, comment) inputs.comment_chain = comment_chain // check whether this chain contains replies from the bot
:robot: OpenAI The function `get_conversation_chain` is renamed to `get_comment_chain`. Please update the function name in this file as well. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -2,12 +2,15 @@ import * as core from '@actions/core' import * as github from '@actions/github' import {Octokit} from '@octokit/action' -import {ChatGPTError} from 'chatgpt' +import {retry} from '@octokit/plugin-retry' const token = core.getInput('token') ? core.getInput('token') : process.env.GITHUB_TOKEN
:robot: OpenAI The ternary operator used here is redundant since the same condition is checked twice. It can be simplified as follows: ```suggestion const token = core.getInput('token') || process.env.GITHUB_TOKEN; ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -2,12 +2,15 @@ import * as core from '@actions/core' import * as github from '@actions/github' import {Octokit} from '@octokit/action' -import {ChatGPTError} from 'chatgpt' +import {retry} from '@octokit/plugin-retry' const token = core.getInput('token') ? core.getInput('token') : process.env.GITHUB_TOKEN -const octokit = new Octokit({auth: `token ${token}`}) + +const RetryOctokit = Octokit.plugin(retry) +const octokit = new RetryOctokit({auth: `token ${token}`})
:robot: OpenAI Good job on adding input sanitization to prevent security vulnerabilities. However, please consider adding more input validation to ensure that the inputs are in the expected format and range. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -297,7 +300,7 @@ ${COMMENT_REPLY_TAG} ) } - async get_conversation_chains_within_range( + async get_comment_chains_within_range( pull_number: number, path: string, start_line: number,
:robot: OpenAI The function name `get_comment_chains_within_range` doesn't accurately describe what the function does. It seems like it should be renamed to something like `get_conversation_chains_within_range`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -534,10 +534,8 @@ ${chain} this.issueCommentsCache[target] = all_comments return all_comments - } catch (e: unknown) { - if (e instanceof ChatGPTError) { - core.warning(`Failed to list comments: ${e}`) - } + } catch (e: any) { + core.warning(`Failed to list comments: ${e}`) return all_comments }
:robot: OpenAI The catch block in this function logs a warning if there is an error listing comments, but it doesn't rethrow the error. This means that the function will always return `all_comments`, even if there was an error. It might be better to rethrow the error so that the caller can handle it appropriately. ```suggestion } catch (e: any) { core.warning(`Failed to list comments: ${e}`); throw e; } ``` Overall, the changes look good and these suggestions should help improve the code. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -1,6 +1,7 @@ import * as core from '@actions/core' import * as github from '@actions/github' import {Octokit} from '@octokit/action' +import {retry} from '@octokit/plugin-retry' import pLimit from 'p-limit' import {Bot} from './bot.js'
:robot: OpenAI ```suggestion log.Info().Msgf("Example") ``` ```go print("Hello!") ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -127,11 +131,10 @@ export const codeReview = async ( continue } const hunks_str = ` -\`\`\`new_hunk +\`\`\`new_hunk_for_review ${hunks.new_hunk} \`\`\` - -\`\`\`old_hunk +\`\`\`old_hunk_for_context ${hunks.old_hunk}
:robot: OpenAI ```diff continue } const hunks_str = ` \`\`\`diff ${hunks.new_hunk} \`\`\` \`\`\`diff ${hunks.old_hunk} \`\`\` ` ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -272,6 +275,10 @@ ${filename}: ${summary} - Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file. - Invite the bot into a review comment chain by tagging \`@openai\` in a reply.
:robot: OpenAI The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned. You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -2,12 +2,12 @@ import * as core from '@actions/core' import * as github from '@actions/github' import {Octokit} from '@octokit/action' -import {ChatGPTError} from 'chatgpt' +import {retry} from '@octokit/plugin-retry' + +const token = core.getInput('token') || process.env.GITHUB_TOKEN; + +const octokit = new Octokit({auth: `token ${token}`}).plugin(retry);
:robot: OpenAI This change adds a new dependency `@octokit/plugin-retry` to the project, which is used to retry failed requests. Please make sure that this new dependency is compatible with all other dependencies and does not introduce any security vulnerabilities. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -297,7 +297,7 @@ ${COMMENT_REPLY_TAG} ) } - async get_conversation_chains_within_range( + async get_comment_chains_within_range( pull_number: number, path: string,
:robot: OpenAI The function name `get_conversation_chains_within_range` has been changed to `get_comment_chains_within_range`. Please make sure that this change is reflected in all other files where this function is called. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -322,7 +322,7 @@ ${COMMENT_REPLY_TAG} let chain_num = 0 for (const top_level_comment of top_level_comments) { // get conversation chain - const chain = await this.compose_conversation_chain( + const chain = await this.compose_comment_chain( existing_comments, top_level_comment )
:robot: OpenAI Please update the comment to reflect the new function name `compose_comment_chain`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -352,14 +349,14 @@ ${chain} return conversationChain.join('\n---\n') } - async get_conversation_chain(pull_number: number, comment: any) { + async get_comment_chain(pull_number: number, comment: any) { try { const review_comments = await this.list_review_comments(pull_number) const top_level_comment = await this.get_top_level_comment( review_comments, comment ) - const chain = await this.compose_conversation_chain( + const chain = await this.compose_comment_chain( review_comments, top_level_comment )
:robot: OpenAI Please update the comment to reflect the new function name `compose_comment_chain`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -72,7 +75,7 @@ export const handleReviewComment = async ( inputs.filename = comment.path const {chain: comment_chain, topLevelComment} = - await commenter.get_conversation_chain(pull_number, comment) + await commenter.get_comment_chain(pull_number, comment) inputs.comment_chain = comment_chain
:robot: OpenAI The function call `get_conversation_chain` on line 78 is not defined in the `Commenter` class. It should be replaced with `get_comment_chain`. Please update the code as follows: ```suggestion 75: inputs.filename = comment.path 76: 77: const {chain: comment_chain, topLevelComment} = 78: await commenter.get_comment_chain(pull_number, comment) 79: inputs.comment_chain = comment_chain 80: 81: // check whether this chain contains replies from the bot ``` <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
typescript
146
coderabbitai
github-actions[bot]
@@ -15,7 +16,9 @@ const token = core.getInput('token') ? core.getInput('token') : process.env.GITHUB_TOKEN -const octokit = new Octokit({auth: `token ${token}`}) +const RetryOctokit = Octokit.plugin(retry) +const octokit = new RetryOctokit({auth: `token ${token}`}) + const context = github.context const repo = context.repo const ASK_BOT = '@openai'
:robot: OpenAI The `Octokit` instance on line 18 should be replaced with a new `RetryOctokit` instance that includes the `retry` plugin. Please update the code as follows: ```suggestion 16: ? core.getInput('token') 17: : process.env.GITHUB_TOKEN 18: 19: const RetryOctokit = Octokit.plugin(retry) 20: const octokit = new RetryOctokit({auth: `token ${token}`}) 21: 22: const context = github.context 23: const repo = context.repo 24: const ASK_BOT = '@openai' ``` Overall, the changes look good and there are no major bug risks or improvement suggestions. Please make the suggested changes and merge the pull request. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
146
coderabbitai
github-actions[bot]
@@ -1957,6 +1958,21 @@ "@octokit/openapi-types": "^12.11.0" } }, + "node_modules/@octokit/plugin-retry": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-4.1.3.tgz", + "integrity": "sha512-3YKBj7d0J/4mpEc4xzMociWsMNl5lZqrpAnYcW6mqiSGF3wFjU+c6GHih6GLClk31JNvKDr0x9jc5cfm7evkZg==", + "dependencies": { + "@octokit/types": "^9.0.0", + "bottleneck": "^2.15.3" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@octokit/core": ">=3" + }
:robot: OpenAI The changes made to `package-lock.json` and `package.json` look good. They add the new dependency `@octokit/plugin-retry` to the project along with its own dependencies, including `bottleneck`. <!-- This is an auto-generated comment by OpenAI -->
ai-pr-reviewer
github_2023
others
146
coderabbitai
github-actions[bot]
@@ -2946,6 +2962,11 @@ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" }, + "node_modules/bottleneck": { + "version": "2.19.5", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" + }, "node_modules/brace-expansion": {
:robot: OpenAI The changes to the dependencies look good. However, please ensure that the new versions are compatible with the existing codebase and do not introduce any security vulnerabilities. Please test the code thoroughly after updating the dependencies. Overall, the changes to the dependencies look good, but it's important to ensure that they are compatible with the existing codebase and do not introduce any security vulnerabilities. <!-- This is an auto-generated comment by OpenAI -->