-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Style Examples
David Honghao Shao edited this page Jun 5, 2018
·
4 revisions
JS:
(1) "," should follow behind its parameter
BAD
this.kernel.connect(this.projectController.address, [ACL_HANDLER_CI
, CONTRACT_ADDRESS_HANDLER_CI]).should.be.fulfilled;
(2) parameters should be in one line. If it exceeds the length, break it into multiple lines. One line has one parameter.
BAD
this.kernel.connect(this.projectController.address, [ACL_HANDLER_CI,
CONTRACT_ADDRESS_HANDLER_CI]).should.be.fulfilled;
GOOD
this.kernel.connect(
this.projectController.address,
[ACL_HANDLER_CI, CONTRACT_ADDRESS_HANDLER_CI]).should.be.fulfilled;
BAD
this.kernel.connect(
this.projectController.address,
[ACL_HANDLER_CI, CONTRACT_ADDRESS_HANDLER_CI,
XYZ_HANDLER_CI, ABSCD_ADDRESS_HANDLER_CI]).should.be.fulfilled;
GOOD
this.kernel.connect(
this.projectController.address,
[ACL_HANDLER_CI,
CONTRACT_ADDRESS_HANDLER_CI,
XYZ_HANDLER_CI,
ABSCD_ADDRESS_HANDLER_CI]).should.be.fulfilled;
(3) keep the completeness of the functionality when breaking codes multiple lines.
BAD
this.aclHandler.permit(ROOT_CI, TOKEN_COLLECTOR_MODULE_CI, WITHDRAW_SIG).should.be
.fulfilled;
GOOD (should.be.fulfilled should be in one line)
this.aclHandler.permit(ROOT_CI, TOKEN_COLLECTOR_MODULE_CI, WITHDRAW_SIG)
.should.be.fulfilled;
BAD
const postStoreTokenBalance = await this.tokenCollectorModule.balanceOf.call(this.token
.address);
GOOD (this.token.address should be one line)
const postStoreTokenBalance = await this.tokenCollectorModule.balanceOf.call(
this.token.address);