-
Notifications
You must be signed in to change notification settings - Fork 23
Feature: Configure approvals number #71
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
Changes from all commits
3191974
7c4c831
a24e2d8
0ebae83
64e1f71
8bdf44e
020a1ed
a8624ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,7 +28,10 @@ export const preparePullRequestTimeline = ( | |||||||||||||||||
| review.user?.login !== pullRequestInfo?.user?.login && | ||||||||||||||||||
| checkUserInclusive(review.user?.login || invalidUserLogin) | ||||||||||||||||||
| ); | ||||||||||||||||||
| const approveTime = getApproveTime(pullRequestReviews); | ||||||||||||||||||
| const approveTime = getApproveTime( | ||||||||||||||||||
| pullRequestReviews, | ||||||||||||||||||
| parseInt(getValueAsIs("REQUIRED_APPROVALS")) | ||||||||||||||||||
| ); | ||||||||||||||||||
|
Comment on lines
+31
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix parseInt usage and add error handling for the config value. The logic correctly passes the required approvals parameter, but there are two improvements needed:
Apply this diff: const approveTime = getApproveTime(
pullRequestReviews,
- parseInt(getValueAsIs("REQUIRED_APPROVALS"))
+ Number.parseInt(getValueAsIs("REQUIRED_APPROVALS") || "1", 10)
);📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 33-33: Use Number.parseInt instead of the equivalent global. ES2015 moved some globals into the Number namespace for consistency. (lint/style/useNumberNamespace) 🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| const timeToReviewRequest = calcDifferenceInMinutes( | ||||||||||||||||||
| pullRequestInfo?.created_at, | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add validation for the requiredApprovals parameter.
Consider adding validation to ensure
requiredApprovalsis a positive integer to prevent unexpected behavior.export const getApproveTime = ( reviews: Awaited<ReturnType<typeof makeComplexRequest>>["events"][number], requiredApprovals: number ) => { + if (requiredApprovals <= 0 || !Number.isInteger(requiredApprovals)) { + throw new Error("requiredApprovals must be a positive integer"); + } + const statuses = Object.values(🤖 Prompt for AI Agents