[rust-guard] Rust Guard: use get_str_or for remaining raw JSON string lookups

クローズ
#15,700 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
54/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
github-actions, rust
領域
tooling

調査の方向性

Start with the listed locations in labels/response_items.rs, labels/response_paths.rs, and labels/backend.rs, then compare them with the existing get_str_or calls in response_items.rs. The report also names labels/constants.rs, labels/tool_rules.rs, and labels/mod.rs for the JSON key constants. Done means applying the stated accessor and constant changes across these sites; the issue suggests running cargo test and a wasm build.

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

説明

refactor rust-guard

🦀 Rust Guard Improvement Report

Improvement 1: Replace raw .get(..).and_then(as_str).unwrap_or("") with get_str_or

Category: Duplication / Idioms
File(s): labels/response_items.rs (L479, L486), labels/response_paths.rs (L597), labels/backend.rs (L1784, in non-test code)
Effort: Small (< 15 min)
Risk: Low

Problem

helpers::get_str_or is the standard accessor (used elsewhere in response_items.rs, e.g. L168, L227, L243), but a few sites still hand-roll the same chain, using bare string literals instead of field_names::*.

Before
let arg_branch = tool_args.get("sha").and_then(|v| v.as_str()).unwrap_or("");
let sha = item.get("sha").and_then(|v| v.as_str()).unwrap_or("");
After
let arg_branch = get_str_or(tool_args, field_names::SHA, "");
let sha = get_str_or(item, field_names::SHA, "");

Apply the same to response_paths.rs:597 and backend.rs:1784 (field_names::NAME if it exists, otherwise add it). Import get_str_or where missing.

Why This Matters

Consistent accessors and constants for field names; fewer duplicated chains. Behavior is identical. Verify with cargo test and the wasm build.


Improvement 2: Add field_names::VISIBILITY / PATH constants

Category: Centralization
File(s): labels/constants.rs, labels/backend.rs:1655, labels/tool_rules.rs:609, labels/mod.rs:140

Raw literals "visibility", "path", "text" are used for JSON keys in non-test code while other keys use field_names::*. Add constants and use them.

Codebase Health Summary

  • Total Rust files: 10 (~24k lines)
  • Areas analyzed: helpers, backend, response_items, response_paths, tool_rules, mod
  • Exhausted: scope_names constants, allow(dead_code), non-test unwrap

Generated by Rust Guard Improver • Run: 40847894215

Generated by Rust Guard Improver · copilot · auto · ~21 AIC · ⊞ 6.1K · ◷

  • expires on Nov 5, 2026, 9:15 AM UTC
主要言語
Go
スター
184
フォーク
56
平均マージ
7時間 23分
マージ済み PR(30日)
183

環境構築

Codespaces で開く

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

はじめの一歩

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

github/gh-aw-mcpg のほかの issue

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

似ている issue

Go の issue をもっと見る

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

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