-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enable GitAuto forge to call GitAuto with payload #24
Conversation
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.
Hey @hiroshinishio - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider removing commented-out code in getIssueDetails response object - if this data isn't needed, remove it entirely; if it might be needed later, add a TODO comment explaining why it's preserved
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟡 Security: 1 issue found
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
issueId, | ||
repository: selectedRepo, | ||
}), | ||
body: JSON.stringify({ ...payload }), |
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.
🚨 suggestion (security): Consider validating payload fields before sending to external service
Spreading the entire payload without validation could lead to sending unexpected data. Consider explicitly mapping required fields.
Suggested implementation:
body: JSON.stringify({
issueId: payload.issueId,
repository: payload.repository,
}),
For even better validation, you might want to add:
- Type checking before the JSON.stringify:
if (!payload.issueId || !payload.repository) {
throw new Error('Missing required fields: issueId and repository are required');
}
- Consider using a validation library like Joi or Zod if you want more robust validation
- Add TypeScript types if the project uses TypeScript
return await response.json(); | ||
}); | ||
|
||
// Convert Atlassian Document Format to Markdown | ||
const adfToMarkdown = (adf) => { |
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.
issue (complexity): Consider extracting common text content logic and flattening the code structure in the ADF to Markdown conversion.
The adfToMarkdown
function can be simplified by extracting common patterns and reducing nesting. Here's a cleaner approach:
const getTextContent = (content) => {
if (!content) return '';
return content.map(item => item.text || '').join('');
};
const adfToMarkdown = (adf) => {
if (!adf?.content) return '';
return adf.content.map((block) => {
const content = block.content || [];
switch (block.type) {
case 'paragraph':
return getTextContent(content) + '\n\n';
case 'heading':
const level = block.attrs?.level || 1;
return '#'.repeat(level) + ' ' + getTextContent(content) + '\n\n';
case 'bulletList':
return content.map(item => `- ${getTextContent(item.content)}`).join('\n') + '\n\n';
case 'orderedList':
return content.map((item, i) => `${i + 1}. ${getTextContent(item.content)}`).join('\n') + '\n\n';
case 'codeBlock':
return '```\n' + getTextContent(content) + '\n```\n\n';
default:
return '';
}
}).join('').trim();
};
This refactoring:
- Extracts common text content mapping into
getTextContent
- Reduces nesting by flattening the structure
- Maintains null safety while being more readable
- Eliminates redundant optional chaining
No description provided.