Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize false positives on WordPressVIPMinimum.Files.IncludingFile.IncludingFile #407

Closed
mdbitz opened this issue Apr 10, 2019 · 4 comments

Comments

@mdbitz
Copy link

mdbitz commented Apr 10, 2019

require_once \PL\PATH . '/inc/endpoints/especiales-endpoint.php';

❗️ Warning: Absolute include path must be used. Use get_template_directory(), get_stylesheet_directory() or plugin_dir_path() (WordPressVIPMinimum.Files.IncludingFile.IncludingFile).

What problem would the enhancement address for VIP?

Currently clients include files be defining path variables or constants that get used for the path. This makes the IncludingFile rule very noisy with false postiives.

Describe the solution you'd like

We should enhance the rule check to account for path variables/constants to reduce false positives.

@mdbitz
Copy link
Author

mdbitz commented Apr 10, 2019

another example.

<?php include Wrapper\template_path(); ?>

@GaryJones GaryJones changed the title We should look into ways to minimize false positives on Minimize false positives on WordPressVIPMinimum.Files.IncludingFile.IncludingFile Apr 11, 2019
@GaryJones
Copy link
Contributor

The variable or constants could be defined in another file, so adding code to check for existence in the current file, and then what value it has, will only reduce noise for a small percentage of cases.

In my experience, a variable or constant would typically be defined in the root of the plugin but is used in a different file in the plugin.

@GaryJones GaryJones added this to the 2.1 milestone Jul 13, 2019
@GaryJones GaryJones modified the milestones: 2.2.0, 2.3.0 Jul 27, 2020
@rebeccahum
Copy link
Contributor

rebeccahum commented Nov 20, 2020

Constants with PATH or DIR or BASE should be not flagged after discussion with @jrfnl. There can be an option to customize with public property for the wording.

@jrfnl
Copy link
Collaborator

jrfnl commented Apr 15, 2021

Closing as the principle premise of this issue has been addressed in #638. Further improvements for this sniff are needed, but will be addressed as part of #514.

@jrfnl jrfnl closed this as completed Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants