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: debug logging and logging logic in ci, local and debug mode #77

Merged
merged 3 commits into from
Aug 2, 2023

Conversation

gowoons
Copy link
Contributor

@gowoons gowoons commented Aug 1, 2023

Closes #56

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2023

LOGAF Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/src/index.ts

  1. The main function is quite long and does multiple things. Consider breaking it down into smaller, more manageable functions.
  2. The switch statement in the main function could be replaced with a lookup object to improve readability and performance.

Example:

const commandHandlers = {
  configure: async () => {...},
  review: async () => {...},
  test: async () => {...},
};

const main = async () => {
  const argv = await getYargs();
  logger.settings.minLevel = argv.debug ? 2 : argv.ci ? 4 : 3;

  const commandHandler = commandHandlers[argv._[0]];
  if (!commandHandler) {
    logger.error("Unknown command");
    process.exit(1);
  }

  await commandHandler();
};

LOGAF Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/src/review/prompt/constructPrompt/constructPrompt.ts

  1. The constructPromptsArray function is quite long and does multiple things. Consider breaking it down into smaller, more manageable functions.
  2. The constructPromptsArray function has a lot of logging statements. Consider creating a separate function for logging to keep the main function clean.

Example:

const logSlimmedFileDetails = (slimmedFile: ReviewFile) => {...};

const getPromptPayloads = async (files: File[], maxPromptPayloadLength: number) => {...};

export const constructPromptsArray = async (files: File[], maxPromptLength: number): Promise<string[]> => {
  const maxPromptPayloadLength = maxPromptLength - instructionPrompt.length;
  const promptPayloads = await getPromptPayloads(files, maxPromptPayloadLength);

  const prompts = promptPayloads.map((payload) => instructionPrompt + JSON.stringify(payload));

  return prompts;
};

LOGAF Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/src/review/llm/askAI.ts

  1. The askAI function is quite long and does multiple things. Consider breaking it down into smaller, more manageable functions.
  2. The askAI function has a lot of logging statements. Consider creating a separate function for logging to keep the main function clean.

Example:

const logFeedbackDetails = (feedbacks: IFeedback[]) => {...};

const getAIResponse = async (model: AIModel, prompts: string[]) => {...};

export const askAI = async (prompts: string[], modelName: string): Promise<AskAIResponse> => {
  logger.info("Asking the experts...");

  const model = new AIModel({modelName: modelName, temperature: 0.0, apiKey: openAIApiKey()});

  const feedbacks = await getAIResponse(model, prompts);

  logFeedbackDetails(feedbacks);

  const summary = await createSummary(model, feedbacks);

  return {markdownReport: generateMarkdownReport(feedbacks, summary), feedbacks: feedbacks};
};

🔨🔀📝


Powered by Code Review GPT

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 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

@gowoons gowoons force-pushed the feat/debug-logging branch from 9fc271c to 346179c Compare August 1, 2023 16:25
@gowoons gowoons marked this pull request as ready for review August 1, 2023 16:39
@mattzcarey mattzcarey merged commit a154cab into main Aug 2, 2023
@mattzcarey mattzcarey deleted the feat/debug-logging branch August 2, 2023 09:44
This was referenced Aug 7, 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.

[Logging] AAUser I can see debug logs in Github actions
2 participants