Skip to content

[code-simplifier] Simplify detection_comparison.py: extract helper functions for casting and legend handling - #58140

Merged
pelikhan merged 1 commit into
mainfrom
code-simplifier/detection-comparison-1788410547-6c8199817a5562f1
Sep 3, 2026
Merged

[code-simplifier] Simplify detection_comparison.py: extract helper functions for casting and legend handling#58140
pelikhan merged 1 commit into
mainfrom
code-simplifier/detection-comparison-1788410547-6c8199817a5562f1

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Caution

Protected files were modified in this change.
This pull request is in request_review mode and requires explicit human scrutiny before merge.

Protected files: .github/scripts/detection_comparison.py

Summary

Extractive, behavior-preserving simplifications to .github/scripts/detection_comparison.py, identified via the recent-change scan (candidate file list) and scored by the simplification scout.

Changes

  • Extracted repeated int(m.get(key, default)) / float(m.get(key, default)) patterns into small get_int/get_float helpers, removing 7x duplicated cast-and-default logic.
  • Extracted the two-axis legend handle/label concatenation (ax1/ax2) into a combined_legend_entries(*axes) helper for clarity, replacing the manual handles1 + handles2 / labels1 + labels2 pattern.

No behavior changes: same JSON keys/defaults are read, same legend content/order is produced, same chart output.

Source references

  • Context and candidate files were derived from deterministic pre-computed inputs (recent-context.json, source-files.json, history-summary.json) rather than re-querying GitHub, per the token-efficiency guidance in history-summary.json's deterministic_candidates.
  • No specific merged PR/commit directly touched this file in the scanned window; it was selected from the general candidate file list.

Validation

  • python3 -m py_compile .github/scripts/detection_comparison.py — passes.
  • This is a standalone Python script with no Go build/lint/test target wired to it (make test-unit, make lint, make build are Go-focused and unaffected by this change); confirmed no Makefile/workflow references detection_comparison.py as a test/lint entry point.
  • Manual diff review confirms all changes are extractive only (helper-function extraction), preserving exact control flow, defaults, and output.

Notes

Other candidate files evaluated (e.g. add_comment.cjs, add_labels.cjs) were larger, higher-risk targets flagged by scope-filter for future passes; this run limited scope to the lowest-risk, fully-validated change to stay within the token/run budget.

Generated by 🔧 Code Simplifier · copilot · auto · 43.9 AIC · ⌖ 10.6 AIC · ⊞ 8.6K ·

  • expires on Sep 3, 2026, 8:45 PM UTC-08:00

…nd legend combiner

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Protected files were modified in this pull request and require manual scrutiny before merge.

Please verify that each protected-file change is intentional, policy-compliant, and safe:

  • Protected files: .github/scripts/detection_comparison.py

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Ponytail Reviewer completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Ponytail Reviewer for #58140

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

Reviewed PR #58140 and submitted a COMMENT review; no separate GitHub write beyond the review was needed.

🔎 Code quality review by PR Code Quality Reviewer

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The modified script is protected and requires explicit human review.

Pull request overview

Refactors chart generation without changing metric parsing or legend output.

Changes:

  • Centralizes integer and float metric conversion.
  • Extracts reusable legend-entry aggregation.
File summaries
File Description
.github/scripts/detection_comparison.py Extracts metric-casting and legend-combination helpers.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Two small simplifications look worth cutting:

  • L30: shrink: local get_int/get_float helpers for six one-line casts. Inline the direct int(m.get(...))/float(m.get(...)) calls.
  • L89: shrink: combined_legend_entries() wrapper around one two-axis legend merge. Inline the two legend fetches and keep the legend call direct.
    net: -8 lines possible.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by ✂️ Ponytail Reviewer for #58140 · codex · mai10 · 3.71 AIC · ⌖ 16.1 AIC · ⊞ 13.5K
Comment /ponytail to run again

regular_failure = int(m.get("regular_failure_count", 0))
detection_failure = int(m.get("detection_failure_count", 0))
misconfigured_count = int(m.get("misconfigured_count", 0))
def get_int(key: str, default: int = 0) -> int:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

L30: shrink: local get_int/get_float helpers for six one-line casts. Inline the direct int(m.get(...))/float(m.get(...)) calls.

handles1, labels1 = ax1.get_legend_handles_labels()
handles2, labels2 = ax2.get_legend_handles_labels()
ax1.legend(handles1 + handles2, labels1 + labels2, loc="upper right", fontsize=10)
def combined_legend_entries(*axes):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

L89: shrink: combined_legend_entries() wrapper around one two-axis legend merge. Inline the two legend fetches and keep the legend call direct.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design lightly — this is a small, low-risk extractive refactor with no behavior changes.

📋 Key Themes & Highlights

Positive Highlights

  • get_int/get_float helpers cleanly remove 7x duplicated cast-and-default logic, matching existing naming style.
  • combined_legend_entries(*axes) generalizes the two-axis handle/label concatenation without changing output order or content.
  • ✅ No new abstractions leak outside main(); scope stays local and easy to follow.

No actionable issues found. py_compile validation was performed per the PR description; no test suite exists for this script.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 15.9 AIC · ⌖ 13.5 AIC · ⊞ 10.3K
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed via Impeccable-style pass. This is a pure Python script refactor (no UI), so Impeccable UI modes (audit/critique/harden/distill/extract/clarify) do not directly apply; treated as a general correctness/maintainability review instead.

The change is a small, behavior-preserving extraction:

  • get_int/get_float helpers replace 7x duplicated int(m.get(key, default)) casts — correct, same keys/defaults.
  • combined_legend_entries(*axes) replaces manual handles1 + handles2 concatenation — correct, same order/content.

No correctness, security, or reliability issues found. No blocking changes needed.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 13 AIC · ⌖ 14.2 AIC · ⊞ 8.3K

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Comment Memory

reviewed_at: 2026-09-03T11:49:27Z
review_event: COMMENT
top_themes: []
files_reviewed:
  - .github/scripts/detection_comparison.py
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 14.7 AIC · ⌖ 7.31 AIC · ⊞ 23.5K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict

No actionable blocking issues found in the changed lines.

Why I'm not blocking this

The patch is a straight helper extraction in .github/scripts/detection_comparison.py: the new get_int/get_float wrappers preserve the same keys and defaults, and combined_legend_entries(ax1, ax2) preserves the original legend ordering and contents. I also discarded the sub-agent result because it referred to a different file outside this diff.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 14.7 AIC · ⌖ 7.31 AIC · ⊞ 23.5K
Comment /review to run again

@pelikhan
pelikhan merged commit ba6872a into main Sep 3, 2026
47 checks passed
@pelikhan
pelikhan deleted the code-simplifier/detection-comparison-1788410547-6c8199817a5562f1 branch September 3, 2026 14:28
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.88.3

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.

2 participants