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

feat: move git commands out of review lambda #46

Merged
merged 5 commits into from
Aug 1, 2023

Conversation

gowoons
Copy link
Contributor

@gowoons gowoons commented Jul 31, 2023

Closes #42

@github-actions
Copy link
Contributor

github-actions bot commented Jul 31, 2023

LOGAF Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/test/load/loadTestCodeSnippets.ts

  • The generateCodeSnippet function could be simplified by using replace and callModel instead of manually constructing the string.

Example:

const generateCodeSnippet = async (testCase: TestCase, model: AIModel): Promise<string> => {
  const prompt = generateCodeSnippetsPrompt.replace('{testCase}', JSON.stringify(testCase));
  const modelResponse = await model.callModel(prompt);
  return modelResponse.replace('```typescript', '').replace('```', '');
};
  • The loadOrGenerateCodeSnippet function seems to be doing too much. Consider breaking it down into smaller, more manageable functions. This can improve readability and maintainability.

LOGAF Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/review/prompt/filterFiles/filterFiles.ts

  • The filterFiles function could be simplified by using filter and some instead of filter and has. This can make the code more readable and easier to understand.

Example:

export const filterFiles = (files: File[]): File[] => {
  return files.filter(file => {
    const ext = extname(file.fileName);
    return supportedFiles.includes(ext) && !excludedKeywords.some(keyword => file.fileName.includes(keyword));
  });
};

LOGAF Level 3 - /home/runner/work/code-review-gpt/code-review-gpt/src/review/prompt/makeSlimmedFile.ts

  • Avoid using console.error for logging in production code. Consider using a proper logging library that can provide more control over log levels, formats, and destinations.
  • The makeSlimmedFile function seems to be doing too much. Consider breaking it down into smaller, more manageable functions. This can improve readability and maintainability.
  • The makeSlimmedFile function could be simplified by using slice and join instead of manually constructing the string.

Example:

export const makeSlimmedFile = async (file: File, maxBatchSize: number): Promise<ReviewFile> => {
  let changedLines: string = file.changedLines;
  if (changedLines.length > maxBatchSize) {
    changedLines = changedLines.slice(0, maxBatchSize);
  }
  const context = await generateContext(changedLines, maxBatchSize);
  const prompt = `${slimmedContextPrompt}
{fileContent: ${changedLines}, context: ${context}}`;
  return { fileName: file.fileName, fileContent: prompt };
};

🔄🔍📝


Powered by Code Review GPT

@github-actions
Copy link
Contributor

github-actions bot commented Jul 31, 2023

Test results summary:

✅ [PASS] - Test case: Bad variable name
✅ [PASS] - Test case: Exposed secret
✅ [PASS] - Test case: Too many nested loops
✅ [PASS] - Test case: Unawaited Promise

SUMMARY: ✅ PASS: 4 - ⚠️ WARN: 0 - ❌ FAIL: 0


Tests Powered by Code Review GPT


expect(result).toBeInstanceOf(Array);
expect(result.length).toBeGreaterThan(0);
console.log(result[0]);
Copy link
Owner

Choose a reason for hiding this comment

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

Probs dont need to log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, forgot to remove it, thanks !

@gowoons gowoons merged commit 6200060 into main Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NPM Packaging] AAReviewLambda I do not contain any git commands
2 participants