update the style guide

This commit is contained in:
Leo Arias 2018-06-29 17:54:44 +00:00
parent 533d5d4b1c
commit 8fdf3f5d45

View File

@ -114,15 +114,15 @@ No::
.. _maximum_line_length: .. _maximum_line_length:
Maximum Line Length Maximum Line Length
=================== ===================
Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ to a maximum of 79 (or 99) Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ to a maximum of 79 (or 99)
characters helps readers easily parse the code. characters helps readers easily parse the code.
Wrapped lines should conform to the following guidelines. Wrapped lines should conform to the following guidelines.
1. The first argument should not be attached to the opening parenthesis. 1. The first argument should not be attached to the opening parenthesis.
2. One, and only one, indent should be used. 2. One, and only one, indent should be used.
3. Each argument should fall on its own line. 3. Each argument should fall on its own line.
4. The terminating element, :code:`);`, should be placed on the final line by itself. 4. The terminating element, :code:`);`, should be placed on the final line by itself.
@ -132,38 +132,38 @@ Function Calls
Yes:: Yes::
thisFunctionCallIsReallyLong( thisFunctionCallIsReallyLong(
longArgument1, longArgument1,
longArgument2, longArgument2,
longArgument3 longArgument3
); );
No:: No::
thisFunctionCallIsReallyLong(longArgument1, thisFunctionCallIsReallyLong(longArgument1,
longArgument2, longArgument2,
longArgument3 longArgument3
); );
thisFunctionCallIsReallyLong(longArgument1, thisFunctionCallIsReallyLong(longArgument1,
longArgument2, longArgument2,
longArgument3 longArgument3
); );
thisFunctionCallIsReallyLong( thisFunctionCallIsReallyLong(
longArgument1, longArgument2, longArgument1, longArgument2,
longArgument3 longArgument3
); );
thisFunctionCallIsReallyLong( thisFunctionCallIsReallyLong(
longArgument1, longArgument1,
longArgument2, longArgument2,
longArgument3 longArgument3
); );
thisFunctionCallIsReallyLong( thisFunctionCallIsReallyLong(
longArgument1, longArgument1,
longArgument2, longArgument2,
longArgument3); longArgument3);
Assignment Statements Assignment Statements
@ -215,7 +215,7 @@ No::
recipient, recipient,
publicKey, publicKey,
amount, amount,
options); options);
Source File Encoding Source File Encoding
==================== ====================
@ -274,7 +274,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last.
Yes:: Yes::
contract A { contract A {
function A() public { constructor() public {
... ...
} }
@ -318,7 +318,7 @@ No::
// Public functions // Public functions
// ... // ...
function A() public { constructor() public {
... ...
} }
@ -529,7 +529,7 @@ No::
function increment(uint x) public pure returns (uint) { function increment(uint x) public pure returns (uint) {
return x + 1;} return x + 1;}
You should explicitly label the visibility of all functions, including constructors. You should explicitly label the visibility of all functions, including constructors.
Yes:: Yes::
@ -540,7 +540,7 @@ Yes::
No:: No::
function implicitlyPublic(uint val) { function implicitlyPublic(uint val) {
doSomething(); doSomething();
} }
The visibility modifier for a function should come before any custom The visibility modifier for a function should come before any custom
@ -663,19 +663,19 @@ Yes::
address a, address a,
address b, address b,
address c address c
) )
public public
returns ( returns (
address someAddressName, address someAddressName,
uint256 LongArgument, uint256 LongArgument,
uint256 Argument uint256 Argument
) )
{ {
doSomething() doSomething()
return ( return (
veryLongReturnArg1, veryLongReturnArg1,
veryLongReturnArg2, veryLongReturnArg2,
veryLongReturnArg3 veryLongReturnArg3
); );
} }
@ -686,16 +686,16 @@ No::
address a, address a,
address b, address b,
address c address c
) )
public public
returns (address someAddressName, returns (address someAddressName,
uint256 LongArgument, uint256 LongArgument,
uint256 Argument) uint256 Argument)
{ {
doSomething() doSomething()
return (veryLongReturnArg1, return (veryLongReturnArg1,
veryLongReturnArg1, veryLongReturnArg1,
veryLongReturnArg1); veryLongReturnArg1);
} }
@ -706,7 +706,7 @@ manner as modifiers if the function declaration is long or hard to read.
Yes:: Yes::
contract A is B, C, D { contract A is B, C, D {
function A(uint param1, uint param2, uint param3, uint param4, uint param5) constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
B(param1) B(param1)
C(param2, param3) C(param2, param3)
D(param4) D(param4)
@ -719,7 +719,7 @@ Yes::
No:: No::
contract A is B, C, D { contract A is B, C, D {
function A(uint param1, uint param2, uint param3, uint param4, uint param5) constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
B(param1) B(param1)
C(param2, param3) C(param2, param3)
D(param4) D(param4)
@ -730,7 +730,7 @@ No::
} }
contract A is B, C, D { contract A is B, C, D {
function A(uint param1, uint param2, uint param3, uint param4, uint param5) constructor(uint param1, uint param2, uint param3, uint param4, uint param5)
B(param1) B(param1)
C(param2, param3) C(param2, param3)
D(param4) D(param4)