Automattic / Automattic/VIP-Coding-Standards

Flag incorrect use of filter (instead of action) before AlwaysReturnSniff

オープン
#399 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
PHP
スター
261
フォーク
44
平均マージ
19分
マージ済み PR(30日)
1

説明

## What problem would the enhancement address for VIP?

Code that uses a filter instead of an action are being flagged with `WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement` when the correct developer remediation for the problematic code should be to change it to `add_action`

## Describe the solution you'd like

Flag use of `add_filter` on hooks that are most definitely only supposed to use `add_action`

Even better, use GitHub "suggestions" to show the correct change.

## What code should be reported as a violation?

`add_filter( 'rss2_item', 'attached_images' );`

## What code should *not* be reported as a violation?

`add_filter( 'the_content', 'my_filter_content' );`

## Additional context

If this raises a flag, then the `WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement` sniff should NOT.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、sniff WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement と、それが add_filter の呼び出しをどのように処理するかを調べます。提供されている rss2_item と the_content の例を比較し、そのうえで、アクション専用の hook は検出される一方で missing-return 違反は検出されないように、hook リストと必要な連携を定義します。この2つの例が要求された結果を出力すれば完了です。

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

評価

技術スタック
php
領域
devtools, tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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