Automattic / Automattic/VIP-Coding-Standards

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

Open
#399 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
261
Forks
44
Avg merge
19m
Merged PRs (30d)
1

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.