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)
Wed, Sep 25, 1:07 AM
Unknown Object (File)
Mon, Sep 9, 10:56 AM
Unknown Object (File)
Mon, Sep 2, 11:19 PM
Unknown Object (File)
Sun, Sep 1, 12:20 PM
Unknown Object (File)
Fri, Aug 30, 12:21 AM
Unknown Object (File)
Thu, Aug 29, 2:42 PM
Unknown Object (File)
Thu, Aug 29, 9:17 AM
Unknown Object (File)
Wed, Aug 28, 6:55 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
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 3573
Build 3581: [Placeholder Plan] Wait for 30 Seconds

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.