Automattic / Automattic/VIP-Coding-Standards

Make suggestion when autoload resolves to true

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

説明

## What problem would the enhancement address for VIP?

Options get marked as autoload=yes when being added, unless there is an explicit setting to no.

For VIP clients, we should flag when it is yes, to remind and encourage developers to consider whether it should be autoload=no, which can help with performance.

## Describe the solution you'd like

PHPCS Warning when `'yes'` or `true` is supplied or implied when calling `add_option()` or `update_option()`.

## What code should be reported as a violation?

```
add_option( 'my_option', 'my_value', '', 'yes' );
add_option( 'my_option', 'my_value', '', true ); // Can be 'yes' string or boolean.
add_option( 'my_option', 'my_value', '' );
add_option( 'my_option', 'my_value' );
add_option( 'my_option' );
update_option( 'my_option', 'my_value', 'yes' );
update_option( 'my_option', 'my_value', true ); // Can be 'yes' string or boolean.
```

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

```
add_option( 'my_option', 'my_value', '', 'no' );
add_option( 'my_option', 'my_value', '', false );
update_option( 'my_option', 'my_value', 'no' );
update_option( 'my_option', 'my_value', false );
```

## Additional context

Some items may indeed be valid to be autoloaded, so it's not an Error in all cases.

This may seem like a bit of noise for some cases, but I think it counts as a good reminder. We can link the error message to [our public docs about autoloading](https://wpvip.com/documentation/vip-go/working-with-wp_options/#autoloading).

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

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

調査の方向性

add_option() と update_option() を扱う PHPCS sniff とテストを見つけ、省略された引数、リテラルの yes/no 値、ブール値がどのように分類されるかを調べる。完了の条件は、一覧にある yes/true/implied のケースでは警告が生成され、no/false のケースでは生成されず、警告から提供された autoloading ドキュメントを参照できること。

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

評価

技術スタック
php
領域
tooling
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

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

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