VIP-Coding-Standards icon indicating copy to clipboard operation
VIP-Coding-Standards copied to clipboard

File inclusion - check for constant defined in the current file

Open GaryJones opened this issue 5 years ago • 1 comments
trafficstars

What problem would the enhancement address for VIP?

The frequency with which "Warning: File inclusion using custom constant (PREFIX_PATH). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant)." shows up just below a line that matches the pattern is high.

Perhaps we can reduce this noise.

Describe the solution you'd like

See if we can improve the sniff, to see if the constant has been defined in the current file, and if so, skip the violation.

What code should be reported as a violation?

require PREFIX_PATH_UNDEFINED_IN_THIS_FILE . '/...';

What code should not be reported as a violation?

define( 'PREFIX_PATH_DEFINED_IN_THIS_FILE', '...' );
...other code...
require PREFIX_PATH_DEFINED_IN_THIS_FILE . '/...';

GaryJones avatar Dec 17 '19 08:12 GaryJones

Noted in JIRA as [GH-3349]

simonwheatley avatar Dec 17 '19 08:12 simonwheatley