Page MenuHomePhabricator

Add a linter rule to detect the use of blacklisted functions
ClosedPublic

Authored by joshuaspence on Oct 12 2014, 11:25 AM.
Tags
None
Referenced Files
F18824516: D10686.id.diff
Thu, Oct 23, 4:01 PM
F18687552: D10686.id.diff
Fri, Sep 26, 2:49 PM
F18674352: D10686.diff
Thu, Sep 25, 2:28 PM
F18656456: D10686.diff
Sep 22 2025, 10:31 PM
F18504260: D10686.id.diff
Sep 4 2025, 11:42 PM
F18376878: D10686.diff
Aug 28 2025, 11:53 AM
F18375955: D10686.id26920.diff
Aug 28 2025, 10:36 AM
F18375507: D10686.id26930.diff
Aug 28 2025, 10:04 AM
Subscribers

Details

Summary

As mentioned in the Phabricator PHP coding standards, the eval function should be avoided. There is some good discussion on StackOverflow as well.

Having said that, instead of hardcoding eval(), I have generalised this enough to allow a set of "blacklisted" functions to be defined with xhpast.blacklisted.function in the .arclint file.

Test Plan

Added a test case.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Add a linter rule to detect the use of `eval`.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.

Maybe we should implement this as xhpast.function-blacklist or similar (like phutil-xhpast.deprecated.functions), which would take a map from function name to explanation? That would be more flexible, at least. Not sure if there are other functions anyone might want to blacklist, though.

joshuaspence retitled this revision from Add a linter rule to detect the use of `eval` to Add a linter rule to detect the use of blacklisted functions.Jan 4 2015, 11:18 PM
joshuaspence updated this object.
joshuaspence edited edge metadata.

Generalised to allow for cusotm blacklisted functions

epriestley edited edge metadata.

Might be YAGNI but it's like 10 extra lines so this seems generally reasonable.

This revision is now accepted and ready to land.Jan 4 2015, 11:30 PM
This revision was automatically updated to reflect the committed changes.