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
Unknown Object (File)
Mar 10 2024, 8:56 AM
Unknown Object (File)
Feb 4 2024, 2:22 PM
Unknown Object (File)
Feb 3 2024, 3:54 PM
Unknown Object (File)
Jan 20 2024, 1:21 AM
Unknown Object (File)
Jan 7 2024, 4:46 AM
Unknown Object (File)
Jan 2 2024, 7:16 PM
Unknown Object (File)
Dec 21 2023, 4:00 PM
Unknown Object (File)
Dec 20 2023, 3:50 PM
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.