Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[duplicate-code] Duplicate Code: pull_request event detection duplicated across safe_update files

オープン 初心者向け
#67,005 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github-actions, go
領域
devtools

調査の方向性

pkg/workflow/safe_update_enforcement.go と pkg/workflow/safe_update_manifest.go を読み、次に呼び出し元の extractPullRequestEventPresenceFromCompiledWorkflow を追ってください。重複しているイベント検出を統合し、呼び出し元を更新して共有実装を使うようにしてください。make fmt と make test-unit を実行してください。safe-update enforcement と manifest detection の両方が引き続き成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

automated-analysis code-quality cookie refactoring
🔍 Duplicate Code Detected: Duplicate pull_request event detection

Analysis of commit 8c2337a

Assignee: @copilot

Summary

extractPullRequestEventPresenceFromOnField and detectPullRequestEvents have byte-for-byte identical bodies (21 normalized lines). Both parse a workflow on: field into (hasPR, hasPRTarget) and both live in the workflow package.

Duplication Details
Pattern: on: field → (pull_request, pull_request_target) presence
  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • pkg/workflow/safe_update_enforcement.go (lines 131-153, extractPullRequestEventPresenceFromOnField)
    • pkg/workflow/safe_update_manifest.go (lines 182-207, detectPullRequestEvents)
  • Code Sample:
    func detectPullRequestEvents(onField any) (hasPR bool, hasPRTarget bool) {
        switch v := onField.(type) {
        case string:
            return v == "pull_request", v == "pull_request_target"
        case []any:
            for _, item := range v {
                event, ok := item.(string)
                if !ok { continue }
                if event == "pull_request" { hasPR = true }
                if event == "pull_request_target" { hasPRTarget = true }
            }
        case map[string]any:
            _, hasPR = v["pull_request"]
            _, hasPRTarget = v["pull_request_target"]
        }
        return hasPR, hasPRTarget
    }
    
Impact Analysis
  • Maintainability: Event-parsing changes must be mirrored across two files.
  • Bug Risk: The two copies can diverge, causing inconsistent safe-update enforcement vs manifest detection.
  • Code Bloat: ~23 duplicated lines across two files in the same package.
Refactoring Recommendations
  1. Extract a single shared helper
    • Keep one function (e.g. detectPullRequestEvents) and have extractPullRequestEventPresenceFromOnField delegate to it, or remove the duplicate and update the one caller (extractPullRequestEventPresenceFromCompiledWorkflow).
    • Estimated effort: ~15 min, low complexity.
    • Benefits: single source of truth for on: event detection.
Implementation Checklist
  • Collapse to one implementation and update callers
  • Run make fmt and make test-unit
  • Verify safe-update enforcement and manifest detection unaffected
Analysis Metadata
  • Analyzed Area: pkg/ non-test .go files
  • Detection Method: normalized function-body hashing + manual verification
  • Commit: 8c2337a

Generated by 🔍 Duplicate Code Detector · pi · opus48 · 52.6 AIC · ⌖ 40.5 AIC · ⊞ 1.5K · ◷

  • expires on Oct 10, 2026, 1:57 PM UTC-08:00
主要言語
Go
スター
5.4k
フォーク
576
平均マージ
8時間 11分
マージ済み PR(30日)
798

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/gh-aw のほかの issue

github/gh-aw の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。