Refactor app_config.rs: collapse the ~18 default_* functions and group fields, with a doc-coverage test to stop drift
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 38/100
調査の方向性
Start with src/app_config.rs, especially AppConfig, its default_* and deserialization helpers, and configuration.md; then inspect the existing config-loading and test setup. The proposal spans default handling, nested structs, serialization compatibility, and documentation coverage, so split the work as suggested and add round-trip tests for existing file and environment layouts. Done means config keys and behavior remain compatible and a test catches public fields missing from the docs.
索引モデルが issue の本文から書いたものです。
説明
Splitting the "app_config.rs is a large multi-responsibility module" item out of #1249 into a concrete, actionable refactor.
Problem
Adding a single config option to src/app_config.rs touches 5+ disconnected places, and nothing makes the compiler tell you when you forgot one:
-
A new field on the ~30-field
AppConfigstruct, usually with its own#[serde(default = "...")]. -
A standalone top-level
default_*()free function returning a literal, declared far away from the field it belongs to. There are 18 of them today:$ grep -c "fn default_" src/app_config.rs 18e.g.
default_max_file_size,default_max_pending_rows,default_oidc_scopes. -
Sometimes a bespoke
deserialize_withhelper:deserialize_port,deserialize_socket_addr,deserialize_site_prefix,deserialize_duration_seconds. -
The env-var name is implicit (resolved by the
configcrate inload_from_file/env_config), so it never appears in code next to the field. -
A hand-maintained row in the
configuration.mdtable. Nothing ties the field to its default to its doc row.
Concrete drift this already caused
The doc comment on max_uploaded_file_size disagrees with its own default function:
- field doc comment, L224:
Maximum size of uploaded files in bytes. The default is 10MiB (10 * 1024 * 1024 bytes) default_max_file_size, L625-L627 actually returns5 * 1024 * 1024(5 MiB)configuration.mdL27 says5242880/ "Defaults to 5 MiB"
So the inline Rust comment drifted to claim 10 MiB while the real default and the docs table both say 5 MiB. Exactly the silent drift this structure invites.
Proposed change
- Move the literal defaults into a single
impl Default for AppConfig(or a const-backed table) and use#[serde(default)], eliminating the ~18default_*free functions and putting each default next to its field. - Group the flat struct into nested domain sub-structs (database, oidc, https, telemetry, markdown) with
#[serde(flatten)], so related field + default + validation co-locate and the file shrinks. - Add a doc-coverage test asserting every public config field name appears in
configuration.md, killing drift mechanically (a value-coverage assertion could also catch the 5/10 MiB case).
Risks and mitigations
serderename/flattencan change the accepted file keys / env var names. Mitigate by keeping field names byte-for-byte identical and adding round-trip tests that load representative existing config files / env layouts and assert the parsedAppConfigis unchanged.- Land the
impl Defaultchange separately from the sub-struct grouping, so each PR is small and the bisect surface stays tight.
Expected win
One place to edit per option, defaults next to their fields, and doc drift caught by a test instead of by a user.
Refs #1249.
- 主要言語
- Rust
- スター
- 2.6k
- フォーク
- 175
- 平均マージ
- 14時間 16分
- マージ済み PR(30日)
- 43
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sqlpage/SQLPage のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
sqlpage/SQLPage#1218 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
There is no convenient way to reproduce issues対応中かも @81reap が 26 日前に担当しました。 オープンenhancement
sqlpage/SQLPage#1566 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Confusing sort interface対応中かも @lovasoa が 73 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
sqlpage/SQLPage#1442 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Mutation Testing Results :: Dead Code + Missing Tests再び着手できるかも @81reap が 61 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
sqlpage/SQLPage#1396 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
sqlpage/SQLPage の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
symposium-dev/symposium#530 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
topgrade-rs/topgrade#2540 ·
メンテナーはふだん 1 日以内に返信
-
Invalid JSON options for ngram and edge_ngram silently use defaults対応中かも @Tilendlesa が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
noemaforge/vimanam#153 ·
メンテナーはふだん 1 日以内に返信