chore(protocol): fix inconsistent named variables in function returns #16162
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For me the pre-finding is a bit ambiguous. First (by the title) it suggests inconsistent use of
named returns
but also says"same return style in all of it is functions”
, later the last sentence says “Consider being consistent with the use of named returns throughout the codebase.”
, which also means (imo) that it is about named variables only (and not applicable where we don’t have a named variable in thereturns
).so it can signal:
variable
vs._variable
everywhere)For me, the former makes more sense, since the latter would result in function body logic changes - a very simple example of that is: TestnetTierProvider getMinTier() -> If we are about to use named variables here, we should modify the if clause to be an if else clause, or adding extra return value to the if, otherwise the flow changes
So I tried to follow the former bullet point to make them consistent:
SgxVerifier
addInstances()
orSignalService
sendSignal()
) And it also helps avoid adding new code logic (e.g.:TestnetTierProvider
getMinTier()
-> If we are about to use named variables here, we should modify the if clause to be an if else clause, or adding extra return value to the if, otherwise the flow changes)_verifyQEReportWithIdentity
)r
is applied as a prefix. Sometimes we had_variable
(to not shadow other vars) and sometimesvariable
only but according to Solidity styling guide,_
shall be only used for private or internal state variables and non-external functions.