From 7e94a1d84d60791d2d1aeec73eae13d58120331f Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 6 May 2016 10:19:28 -0400 Subject: Added a clause about short functions --- docs/style-guide.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/style-guide.rst b/docs/style-guide.rst index bc32f891..ef2c334f 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -482,6 +482,11 @@ No:: } } +When declaring short functions with a single statement, it is permissible to do it on a single line. + +Permissible:: + + function shortFunction() { doSomething(); } These guidelines for function declarations are intended to improve readability. Authors should use their best judgement as this guide does not try to cover all -- cgit From d4125c4f07b3f33e46cff2429616d50336c77e8c Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 6 May 2016 10:25:18 -0400 Subject: Changed do_something to doSomething This is in accordance to the style guide --- docs/style-guide.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/style-guide.rst b/docs/style-guide.rst index ef2c334f..a6582b1b 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -365,14 +365,14 @@ Yes:: address e, address f, ) { - do_something; + doSomething(); } No:: function thisFunctionHasLotsOfArguments(address a, address b, address c, address d, address e, address f) { - do_something; + doSomething(); } function thisFunctionHasLotsOfArguments(address a, @@ -381,7 +381,7 @@ No:: address d, address e, address f) { - do_something; + doSomething(); } function thisFunctionHasLotsOfArguments( @@ -391,7 +391,7 @@ No:: address d, address e, address f) { - do_something; + doSomething(); } If a long function declaration has modifiers, then each modifier should be @@ -405,7 +405,7 @@ Yes:: priced returns (address) { - do_something; + doSomething(); } function thisFunctionNameIsReallyLong( @@ -418,7 +418,7 @@ Yes:: priced returns (address) { - do_something; + doSomething(); } No:: @@ -428,13 +428,13 @@ No:: onlyowner priced returns (address) { - do_something; + doSomething(); } function thisFunctionNameIsReallyLong(address x, address y, address z) public onlyowner priced returns (address) { - do_something; + doSomething(); } function thisFunctionNameIsReallyLong(address x, address y, address z) @@ -442,7 +442,7 @@ No:: onlyowner priced returns (address) { - do_something; + doSomething(); } For constructor functions on inherited contracts who's bases require arguments, -- cgit From b6fd6ddc996af702071bee7b8cb75976ae1bc3f3 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Fri, 6 May 2016 10:36:32 -0400 Subject: Change whitespace section to include exception For single-line functions, some whitespace padding makes the functions slightly more readable. --- docs/style-guide.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/style-guide.rst b/docs/style-guide.rst index a6582b1b..9f1bcad5 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -155,7 +155,7 @@ Whitespace in Expressions Avoid extraneous whitespace in the following situations: -Immediately inside parenthesis, brackets or braces. +Immediately inside parenthesis, brackets or braces, with the exception of single-line function declarations. Yes:: @@ -165,6 +165,10 @@ No:: spam( ham[ 1 ], Coin( { name: "ham" } ) );` +Exception:: + + function singleLine() { spam(); } + Immediately before a comma, semicolon: Yes:: -- cgit