Automattic / Automattic/VIP-Coding-Standards
Flag incorrect use of filter (instead of action) before AlwaysReturnSniff
- 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?
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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách xem xét sniff WordPressVIPMinimum.Filters.AlwaysReturn.missingReturnStatement và cách nó xử lý các lệnh gọi add_filter. So sánh các ví dụ rss2_item và the_content được cung cấp, sau đó xác định danh sách hook và tương tác cần thiết để các hook chỉ dùng cho action bị phát hiện, còn vi phạm thiếu giá trị trả về thì không; hoàn tất khi hai ví dụ này cho ra các kết quả được yêu cầu.
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
- devtools, tooling
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100