Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #3

Merged
merged 5 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inputs:
ENABLE_TELEGRAM_BOT:
description: "Enable Telegram bot functionality"
required: false
default: 'false'
default: "false"

BOT_NAME:
description: "Name of the bot that will appear in comments"
Expand All @@ -49,4 +49,4 @@ runs:
branding:
icon: "cpu"
color: "red"
author: 'Blizzer'
author: "Blizzer"
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ exports.config = {
telegram: {
botToken: core.getInput("TELEGRAM_BOT_TOKEN"),
chatId: core.getInput("TELEGRAM_CHAT_ID"),
enableBot: core.getInput("ENABLE_TELEGRAM_BOT") === 'true',
enableBot: core.getInput("ENABLE_TELEGRAM_BOT") === "true",
},
bot: {
name: core.getInput("BOT_NAME") || "Intellizzer",
Expand Down Expand Up @@ -315,18 +315,22 @@ class GitHubService {
console.log("Creating comment:", {
path: comment.path,
line: comment.line,
diff_hunk: comment.diff_hunk,
});
// Calculate position from diff_hunk
const position = comment.diff_hunk
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The calculation of position should handle cases where comment.diff_hunk might not contain any lines starting with + or -. This could lead to unexpected results if the findIndex method returns -1, which would cause an incorrect position to be used.

.split("\n")
.findIndex((line) => line.startsWith("+") || line.startsWith("-")) + 1;
yield this.octokit.pulls.createReviewComment({
owner,
repo,
pull_number,
body: comment.body,
path: comment.path,
position,
line: comment.line,
commit_id: comment.commit_id,
side: "RIGHT",
diff_hunk: comment.diff_hunk,
in_reply_to: undefined, // Add optional in_reply_to parameter
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The in_reply_to parameter is set to undefined. If this is intended to be optional, ensure that the API can handle undefined values appropriately, or consider removing it if not needed.

});
// Add a small delay between comments
yield new Promise((resolve) => setTimeout(resolve, 1000));
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports.config = {
telegram: {
botToken: core.getInput("TELEGRAM_BOT_TOKEN"),
chatId: core.getInput("TELEGRAM_CHAT_ID"),
enableBot: core.getInput("ENABLE_TELEGRAM_BOT") === 'true',
enableBot: core.getInput("ENABLE_TELEGRAM_BOT") === "true",
},
bot: {
name: core.getInput("BOT_NAME") || "Intellizzer",
Expand Down
8 changes: 6 additions & 2 deletions lib/services/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,22 @@ class GitHubService {
console.log("Creating comment:", {
path: comment.path,
line: comment.line,
diff_hunk: comment.diff_hunk,
});
// Calculate position from diff_hunk
const position = comment.diff_hunk
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The variable position is calculated based on the assumption that the first line starting with + or - is the correct position. This may not always be accurate. Consider revising the logic to ensure it correctly identifies the intended position in all cases.

.split("\n")
.findIndex((line) => line.startsWith("+") || line.startsWith("-")) + 1;
yield this.octokit.pulls.createReviewComment({
owner,
repo,
pull_number,
body: comment.body,
path: comment.path,
position,
line: comment.line,
commit_id: comment.commit_id,
side: "RIGHT",
diff_hunk: comment.diff_hunk,
in_reply_to: undefined, // Add optional in_reply_to parameter
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The in_reply_to parameter is set to undefined. If this is intended to be optional, it might be better to omit it entirely rather than explicitly setting it to undefined.

});
// Add a small delay between comments
yield new Promise((resolve) => setTimeout(resolve, 1000));
Expand Down
5 changes: 3 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const config = {
openai: {
apiKey: core.getInput("OPENAI_API_KEY"),
model: core.getInput("OPENAI_API_MODEL"),
apiEndpoint: core.getInput("OPENAI_API_ENDPOINT") || "https://api.openai.com/v1",
apiEndpoint:
core.getInput("OPENAI_API_ENDPOINT") || "https://api.openai.com/v1",
queryConfig: {
temperature: 0.2,
max_tokens: 700,
Expand All @@ -19,7 +20,7 @@ export const config = {
telegram: {
botToken: core.getInput("TELEGRAM_BOT_TOKEN"),
chatId: core.getInput("TELEGRAM_CHAT_ID"),
enableBot: core.getInput("ENABLE_TELEGRAM_BOT") === 'true',
enableBot: core.getInput("ENABLE_TELEGRAM_BOT") === "true",
},
bot: {
name: core.getInput("BOT_NAME") || "Intellizzer",
Expand Down
14 changes: 11 additions & 3 deletions src/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,27 @@ export class GitHubService {
console.log("Creating comment:", {
path: comment.path,
line: comment.line,
diff_hunk: comment.diff_hunk,
});

// Calculate position from diff_hunk
const position =
comment.diff_hunk
.split("\n")
.findIndex(
(line) => line.startsWith("+") || line.startsWith("-")
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The use of findIndex here could lead to unexpected results if the diff_hunk does not contain any lines starting with + or -. Consider adding a check to handle such cases.

) + 1;

await this.octokit.pulls.createReviewComment({
owner,
repo,
pull_number,
body: comment.body,
path: comment.path,
line: comment.line,
position,
line: comment.line, // Add required line parameter
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The comment // Add required line parameter is unnecessary and should be removed to maintain code clarity.

commit_id: comment.commit_id,
side: "RIGHT",
Copy link

Choose a reason for hiding this comment

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

Intellizzer:

The comment // Add optional in_reply_to parameter is unnecessary and should be removed to maintain code clarity.

diff_hunk: comment.diff_hunk,
in_reply_to: undefined, // Add optional in_reply_to parameter
});

// Add a small delay between comments
Expand Down