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

Add configuration option to control publish of no code suggestions message #1331

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

miyagi-do
Copy link
Contributor

@miyagi-do miyagi-do commented Nov 1, 2024

User description

This should resolve #1315


PR Type

Enhancement


Description

  • Added a new configuration option publish_output_no_suggestions to control whether a "No code suggestions found for the PR." message is posted.
  • Updated the logic in pr_code_suggestions.py to check the new configuration before posting the message.
  • Enhanced the configuration file to include the new option.

Changes walkthrough 📝

Relevant files
Enhancement
pr_code_suggestions.py
Add configuration to control "no suggestions" message       

pr_agent/tools/pr_code_suggestions.py

  • Added a configuration check for publishing "no code suggestions"
    message.
  • Wrapped the message publishing logic with a new configuration option.
  • +9/-6     
    Configuration changes
    configuration.toml
    Add `publish_output_no_suggestions` configuration option 

    pr_agent/settings/configuration.toml

  • Introduced a new configuration option publish_output_no_suggestions.
  • +1/-0     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    1315 - Fully compliant

    Fully compliant requirements:

    • Add a configuration option to turn off the "no code suggestions" message
    • The PR agent should not post anything if no code suggestions were found when this option is enabled
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🏅 Score: 95
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Clarity
    The nested if statements could be simplified for better readability

    Copy link
    Contributor

    codiumai-pr-agent-pro bot commented Nov 1, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Extract complex logic into separate functions for improved readability and maintainability

    Consider extracting the condition for publishing no suggestions into a separate
    function to improve code readability and maintainability.

    pr_agent/tools/pr_code_suggestions.py [117-123]

    -if (get_settings().config.publish_output_no_suggestions):
    +def should_publish_no_suggestions():
    +    return get_settings().config.publish_output_no_suggestions
    +
    +def publish_no_suggestions_message(self):
         pr_body = "\n\nNo code suggestions found for the PR."
         get_logger().debug(f"PR output", artifact=pr_body)
         if self.progress_response:
             self.git_provider.edit_comment(self.progress_response, body=pr_body)
         else:
             self.git_provider.publish_comment(pr_body)
     
    +if should_publish_no_suggestions():
    +    publish_no_suggestions_message(self)
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Extracting the logic for publishing no suggestions into separate functions improves code readability and maintainability by isolating specific functionality. This change is beneficial for future code modifications and understanding.

    7
    Enhancement
    Improve variable naming for better code readability and understanding

    Consider using a more descriptive variable name instead of data to improve code
    readability. For example, code_suggestions_data would better reflect the content and
    purpose of the variable.

    pr_agent/tools/pr_code_suggestions.py [110-114]

    -if not data:
    -    data = {"code_suggestions": []}
    +if not code_suggestions_data:
    +    code_suggestions_data = {"code_suggestions": []}
     
    -if (data is None or 'code_suggestions' not in data or not data['code_suggestions']
    +if (code_suggestions_data is None or 'code_suggestions' not in code_suggestions_data or not code_suggestions_data['code_suggestions']
             and get_settings().config.publish_output):
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: The suggestion to rename the variable 'data' to 'code_suggestions_data' enhances readability by making the variable's purpose clearer. However, the impact is moderate as the existing code is still understandable.

    5
    • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

    💡 Need additional feedback ? start a PR chat

    @mrT23 mrT23 merged commit 93ba2d2 into Codium-ai:main Nov 4, 2024
    2 checks passed
    @miyagi-do miyagi-do deleted the nocode_suggestions_config branch November 4, 2024 13:16
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Add configuration option to not post anything if no code suggestions were found
    2 participants