From c1fa22d0681b6a659bf306c7841220f7bc074b5b Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 23 Jan 2025 11:18:00 +0200 Subject: [PATCH 1/2] refactor: simplify review effort label format and remove maximal effort limit --- docs/docs/tools/review.md | 10 ---------- pr_agent/settings/configuration.toml | 1 - pr_agent/tools/pr_reviewer.py | 18 ++---------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index 9f1d19b06..6ce96696d 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -123,10 +123,6 @@ If enabled, the `review` tool can approve a PR when a specific comment, `/review enable_auto_approval If set to true, the tool will approve the PR when invoked with the 'auto_approve' command. Default is false. This flag can be changed only from a configuration file. - - maximal_review_effort - Maximal effort level for auto-approval. If the PR's estimated review effort is above this threshold, the auto-approval will not run. Default is 5. - ## Usage Tips @@ -198,12 +194,6 @@ If enabled, the `review` tool can approve a PR when a specific comment, `/review Qodo Merge will automatically approve the PR, and add a comment with the approval. - You can also enable auto-approval only if the PR meets certain requirements, such as that the `estimated_review_effort` label is equal or below a certain threshold, by adjusting the flag: - ``` - [pr_reviewer] - maximal_review_effort = 5 - ``` - !!! tip "Code suggestions" The `review` tool previously included a legacy feature for providing code suggestions (controlled by `--pr_reviewer.num_code_suggestion`). This functionality has been deprecated and replaced by the [`improve`](./improve.md) tool, which offers higher quality and more actionable code suggestions. diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 681570d02..d285b01aa 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -71,7 +71,6 @@ enable_intro_text=true enable_help_text=false # Determines whether to include help text in the PR review. Enabled by default. # auto approval enable_auto_approval=false -maximal_review_effort=5 [pr_description] # /describe # diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index ee3bb963f..6827290dd 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -371,7 +371,7 @@ def set_review_labels(self, data): else: get_logger().warning(f"Unexpected type for estimated_effort: {type(estimated_effort)}") if 1 <= estimated_effort_number <= 5: # 1, because ... - review_labels.append(f'Review effort [1-5]: {estimated_effort_number}') + review_labels.append(f'Review effort: {estimated_effort_number}/5') if get_settings().pr_reviewer.enable_review_labels_security and get_settings().pr_reviewer.require_security_review: security_concerns = data['review']['security_concerns'] # yes, because ... security_concerns_bool = 'yes' in security_concerns.lower() or 'true' in security_concerns.lower() @@ -384,7 +384,7 @@ def set_review_labels(self, data): get_logger().debug(f"Current labels:\n{current_labels}") if current_labels: current_labels_filtered = [label for label in current_labels if - not label.lower().startswith('review effort [1-5]:') and not label.lower().startswith( + not label.lower().startswith('review effort:') and not label.lower().startswith( 'possible security concern')] else: current_labels_filtered = [] @@ -402,20 +402,6 @@ def auto_approve_logic(self): Auto-approve a pull request if it meets the conditions for auto-approval. """ if get_settings().pr_reviewer.enable_auto_approval: - maximal_review_effort = get_settings().pr_reviewer.maximal_review_effort - if maximal_review_effort < 5: - current_labels = self.git_provider.get_pr_labels() - for label in current_labels: - if label.lower().startswith('review effort [1-5]:'): - effort = int(label.split(':')[1].strip()) - if effort > maximal_review_effort: - get_logger().info( - f"Auto-approve error: PR review effort ({effort}) is higher than the maximal review effort " - f"({maximal_review_effort}) allowed") - self.git_provider.publish_comment( - f"Auto-approve error: PR review effort ({effort}) is higher than the maximal review effort " - f"({maximal_review_effort}) allowed") - return is_auto_approved = self.git_provider.auto_approve() if is_auto_approved: get_logger().info("Auto-approved PR") From 94616a342966a10d3958716a6ecac0a7110546dc Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 23 Jan 2025 11:20:58 +0200 Subject: [PATCH 2/2] refactor: simplify review effort label format and remove maximal effort limit --- pr_agent/tools/pr_reviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 6827290dd..fefef10ab 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -384,7 +384,7 @@ def set_review_labels(self, data): get_logger().debug(f"Current labels:\n{current_labels}") if current_labels: current_labels_filtered = [label for label in current_labels if - not label.lower().startswith('review effort:') and not label.lower().startswith( + not label.lower().startswith('review effort') and not label.lower().startswith( 'possible security concern')] else: current_labels_filtered = []