hujsonfmt: -w rewrites already formatted files and -l lists them

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
tooling

調査の方向性

cmd/hujsonfmt/hujsonfmt.goを読み、特にprocessFileとprocessSrcを確認してください。-lと-wの両方について、元のsrcとフォーマット後の出力を比較してください。次に、すでにフォーマット済みのファイルは一覧に表示も再書き込みもされず、未フォーマットのファイルは更新されることを確認してください。Issueには、動作を検証するための再現可能なコマンド手順が記載されています。

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

説明

hujsonfmt -w rewrites a file that is already formatted, and hujsonfmt -l lists it as unformatted.

Steps, with hujsonfmt 0-unstable-2025-06-05 from nixpkgs on Linux; cmd/hujsonfmt/hujsonfmt.go at b80ff77 has the same code:

printf '{\n\t"a": 1,\n}\n' > policy.hujson
hujsonfmt -w policy.hujson          # formats it
hujsonfmt policy.hujson | diff - policy.hujson   # no output: already formatted
hujsonfmt -w policy.hujson          # mtime changes again
hujsonfmt -l policy.hujson          # prints policy.hujson

processFile passes input to processSrc, which can modify it in place, so the -l case compares the modified input with the output instead of src. The -w case calls writeFile without comparing at all, so every run writes a backup copy and rewrites the file. Formatters such as treefmt then report the file as changed on every run.

Would a fix that compares src with the output in both cases, and skips the write when they are equal, be welcome?

主要言語
Go
スター
892
フォーク
40
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

tailscale/hujson のほかの issue

tailscale/hujson の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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