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)
Sat, Dec 21, 12:20 PM
Unknown Object (File)
Fri, Dec 20, 6:03 PM
Unknown Object (File)
Sun, Dec 8, 3:12 AM
Unknown Object (File)
Wed, Dec 4, 6:33 AM
Unknown Object (File)
Thu, Nov 28, 5:10 PM
Unknown Object (File)
Thu, Nov 28, 5:10 PM
Unknown Object (File)
Thu, Nov 28, 5:10 PM
Unknown Object (File)
Thu, Nov 28, 5:10 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.