Automattic / Automattic/VIP-Coding-Standards
Make suggestion when autoload resolves to true
- Ngôn ngữ chính
- PHP
- Star
- 261
- Fork
- 44
- Merge trung bình
- 19 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
## 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).
Hướng dẫn đóng góp
Hướng nghiên cứu
Tìm PHPCS sniff và các test xử lý add_option() và update_option(); kiểm tra cách các đối số bị bỏ qua, các giá trị yes/no literal và các giá trị boolean được phân loại. Được xem là hoàn tất khi các trường hợp yes/true/implied được liệt kê tạo ra cảnh báo, các trường hợp no/false không tạo ra cảnh báo và cảnh báo có thể tham chiếu đến tài liệu autoloading được cung cấp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- php
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 48/100