Merge pull request #7684 from ethereum/add_while_style_rule

Add ``switch (..)` to style checker
This commit is contained in:
chriseth 2019-11-11 17:56:46 +01:00 committed by GitHub
commit 5423dd6a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 11 additions and 11 deletions

View File

@ -29,7 +29,7 @@ using namespace langutil;
Error::Error(Type _type, SourceLocation const& _location, string const& _description):
m_type(_type)
{
switch(m_type)
switch (m_type)
{
case Type::DeclarationError:
m_typeName = "DeclarationError";

View File

@ -49,7 +49,7 @@ bool ControlFlowBuilder::visit(BinaryOperation const& _operation)
{
solAssert(!!m_currentNode, "");
switch(_operation.getOperator())
switch (_operation.getOperator())
{
case Token::Or:
case Token::And:

View File

@ -126,7 +126,7 @@ bool ReferencesResolver::visit(ElementaryTypeName const& _typeName)
{
// for non-address types this was already caught by the parser
solAssert(_typeName.annotation().type->category() == Type::Category::Address, "");
switch(*_typeName.stateMutability())
switch (*_typeName.stateMutability())
{
case StateMutability::Payable:
_typeName.annotation().type = TypeProvider::payableAddress();

View File

@ -187,7 +187,7 @@ public:
static std::string visibilityToString(Declaration::Visibility _visibility)
{
switch(_visibility)
switch (_visibility)
{
case Declaration::Visibility::Public:
return "public";

View File

@ -36,7 +36,7 @@ enum class StateMutability { Pure, View, NonPayable, Payable };
inline std::string stateMutabilityToString(StateMutability const& _stateMutability)
{
switch(_stateMutability)
switch (_stateMutability)
{
case StateMutability::Pure:
return "pure";

View File

@ -658,7 +658,7 @@ BoolResult FixedPointType::isExplicitlyConvertibleTo(Type const& _convertTo) con
TypeResult FixedPointType::unaryOperatorResult(Token _operator) const
{
switch(_operator)
switch (_operator)
{
case Token::Delete:
// "delete" is ok for all fixed types
@ -2846,7 +2846,7 @@ unsigned FunctionType::sizeOnStack() const
unsigned size = 0;
switch(kind)
switch (kind)
{
case Kind::External:
case Kind::DelegateCall:

View File

@ -241,7 +241,7 @@ ASTPointer<ImportDirective> Parser::parseImportDirective()
ContractDefinition::ContractKind Parser::parseContractKind()
{
ContractDefinition::ContractKind kind;
switch(m_scanner->currentToken())
switch (m_scanner->currentToken())
{
case Token::Interface:
kind = ContractDefinition::ContractKind::Interface;
@ -388,7 +388,7 @@ StateMutability Parser::parseStateMutability()
{
StateMutability stateMutability(StateMutability::NonPayable);
Token token = m_scanner->currentToken();
switch(token)
switch (token)
{
case Token::Payable:
stateMutability = StateMutability::Payable;

View File

@ -113,7 +113,7 @@ u256 yul::valueOfBoolLiteral(Literal const& _literal)
u256 yul::valueOfLiteral(Literal const& _literal)
{
switch(_literal.kind)
switch (_literal.kind)
{
case LiteralKind::Number:
return valueOfNumberLiteral(_literal);

View File

@ -17,7 +17,7 @@ fi
FORMATERROR=$(
(
git grep -nIE "\<(if|for|while)\(" -- '*.h' '*.cpp' # no space after "if", "for" or "while"
git grep -nIE "\<(if|for|while|switch)\(" -- '*.h' '*.cpp' # no space after "if", "for", "while" or "switch"
git grep -nIE "\<for\>\s*\([^=]*\>\s:\s.*\)" -- '*.h' '*.cpp' # no space before range based for-loop
git grep -nIE "\<if\>\s*\(.*\)\s*\{\s*$" -- '*.h' '*.cpp' # "{\n" on same line as "if" / "for"
git grep -nIE "[,\(<]\s*const " -- '*.h' '*.cpp' # const on left side of type