0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHPStan の出力結果 (JSON 形式) を CSV に変換する

0
Posted at

レポート用に CSV 出力したかったんですが、標準のフォーマット選択肢ではサポートされていなかったのでワンライナーで変換しました。

環境

  • PHP: 8.3.22
  • Composer: 2.8.9
  • PHPStan: 2.1.22

変換方法

PHPStan の設定は以下の通り。

phpstan.neon
parameters:
  level: 5
  errorFormat: prettyJson
  # (以下略)

PHPStan の実行:

$ composer exec phpstan -- analyze > phpstan-result.json

JSON を CSV に変換:

$ jq -r '
  (.files | to_entries[] | . as $file | .value.messages[] | [
    $file.key,
    .line,
    .message,
    (.ignorable | tostring),
    .identifier
  ]) | @csv
' phpstan-result.json
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?