More style checks.

This commit is contained in:
Daniel Kirchner 2019-02-14 11:37:24 +01:00
parent f003696d7e
commit 8ca6715e18
11 changed files with 16 additions and 13 deletions

View File

@ -240,7 +240,7 @@ bool contains(T const& _t, V const& _v)
/// place at the end, but already visited elements might be invalidated. /// place at the end, but already visited elements might be invalidated.
/// If nothing is replaced, no copy is performed. /// If nothing is replaced, no copy is performed.
template <typename T, typename F> template <typename T, typename F>
void iterateReplacing(std::vector<T>& _vector, const F& _f) void iterateReplacing(std::vector<T>& _vector, F const& _f)
{ {
// Concept: _f must be Callable, must accept param T&, must return optional<vector<T>> // Concept: _f must be Callable, must accept param T&, must return optional<vector<T>>
bool useModified = false; bool useModified = false;

View File

@ -134,7 +134,7 @@ void ErrorReporter::clear()
m_errorList.clear(); m_errorList.clear();
} }
void ErrorReporter::declarationError(SourceLocation const& _location, SecondarySourceLocation const&_secondaryLocation, string const& _description) void ErrorReporter::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, string const& _description)
{ {
error( error(
Error::Type::DeclarationError, Error::Type::DeclarationError,

View File

@ -57,7 +57,7 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip
*this << errinfo_comment(_description); *this << errinfo_comment(_description);
} }
Error::Error(Error::Type _type, const std::string& _description, const SourceLocation& _location): Error::Error(Error::Type _type, std::string const& _description, SourceLocation const& _location):
Error(_type) Error(_type)
{ {
if (!_location.isEmpty()) if (!_location.isEmpty())

View File

@ -653,7 +653,7 @@ void CompilerUtils::convertType(
bool chopSignBitsPending = _chopSignBits && targetTypeCategory == Type::Category::Integer; bool chopSignBitsPending = _chopSignBits && targetTypeCategory == Type::Category::Integer;
if (chopSignBitsPending) if (chopSignBitsPending)
{ {
const IntegerType& targetIntegerType = dynamic_cast<const IntegerType &>(_targetType); const IntegerType& targetIntegerType = dynamic_cast<IntegerType const&>(_targetType);
chopSignBitsPending = targetIntegerType.isSigned(); chopSignBitsPending = targetIntegerType.isSigned();
} }

View File

@ -355,7 +355,7 @@ bool hasPayableFunctions(ContractDefinition const& _contract)
void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contract) void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contract)
{ {
map<FixedHash<4>, FunctionTypePointer> interfaceFunctions = _contract.interfaceFunctions(); map<FixedHash<4>, FunctionTypePointer> interfaceFunctions = _contract.interfaceFunctions();
map<FixedHash<4>, const eth::AssemblyItem> callDataUnpackerEntryPoints; map<FixedHash<4>, eth::AssemblyItem const> callDataUnpackerEntryPoints;
if (_contract.isLibrary()) if (_contract.isLibrary())
{ {

View File

@ -473,7 +473,7 @@ void StorageByteArrayElement::setToZero(SourceLocation const&, bool _removeRefer
m_context << Instruction::SWAP1 << Instruction::SSTORE; m_context << Instruction::SWAP1 << Instruction::SSTORE;
} }
StorageArrayLength::StorageArrayLength(CompilerContext& _compilerContext, const ArrayType& _arrayType): StorageArrayLength::StorageArrayLength(CompilerContext& _compilerContext, ArrayType const& _arrayType):
LValue(_compilerContext, _arrayType.memberType("length").get()), LValue(_compilerContext, _arrayType.memberType("length").get()),
m_arrayType(_arrayType) m_arrayType(_arrayType)
{ {

View File

@ -65,7 +65,7 @@ smt::Expression SymbolicVariable::increaseIndex()
SymbolicBoolVariable::SymbolicBoolVariable( SymbolicBoolVariable::SymbolicBoolVariable(
TypePointer _type, TypePointer _type,
string const& _uniqueName, string const& _uniqueName,
smt::SolverInterface&_interface smt::SolverInterface& _interface
): ):
SymbolicVariable(move(_type), _uniqueName, _interface) SymbolicVariable(move(_type), _uniqueName, _interface)
{ {
@ -102,7 +102,7 @@ SymbolicFixedBytesVariable::SymbolicFixedBytesVariable(
SymbolicFunctionVariable::SymbolicFunctionVariable( SymbolicFunctionVariable::SymbolicFunctionVariable(
TypePointer _type, TypePointer _type,
string const& _uniqueName, string const& _uniqueName,
smt::SolverInterface&_interface smt::SolverInterface& _interface
): ):
SymbolicVariable(move(_type), _uniqueName, _interface), SymbolicVariable(move(_type), _uniqueName, _interface),
m_declaration(m_interface.newVariable(currentName(), smtSort(*m_type))) m_declaration(m_interface.newVariable(currentName(), smtSort(*m_type)))

View File

@ -118,7 +118,7 @@ string Natspec::extractDoc(multimap<string, DocTag> const& _tags, string const&
return value; return value;
} }
Json::Value Natspec::devDocumentation(std::multimap<std::string, DocTag> const &_tags) Json::Value Natspec::devDocumentation(std::multimap<std::string, DocTag> const& _tags)
{ {
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
auto dev = extractDoc(_tags, "dev"); auto dev = extractDoc(_tags, "dev");

View File

@ -59,7 +59,7 @@ private:
/// @param _tags docTags that are used. /// @param _tags docTags that are used.
/// @return A JSON representation /// @return A JSON representation
/// of the contract's developer documentation /// of the contract's developer documentation
static Json::Value devDocumentation(std::multimap<std::string, DocTag> const &_tags); static Json::Value devDocumentation(std::multimap<std::string, DocTag> const& _tags);
}; };
} //solidity NS } //solidity NS

View File

@ -44,8 +44,8 @@ public:
void operator()(Block& _block) override; void operator()(Block& _block) override;
private: private:
void simplify(std::vector<Statement>& _statements); void simplify(std::vector<Statement>& _statements);
bool expressionAlwaysTrue(Expression const &_expression); bool expressionAlwaysTrue(Expression const& _expression);
bool expressionAlwaysFalse(Expression const &_expression); bool expressionAlwaysFalse(Expression const& _expression);
}; };
} }

View File

@ -19,8 +19,11 @@ FORMATERROR=$(
( (
git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' # no space after "if" or "for" git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' # no space after "if" or "for"
git grep -nIE "\<if\>\s*\(.*\)\s*\{\s*$" -- '*.h' '*.cpp' # "{\n" on same line as "if" / "for" git grep -nIE "\<if\>\s*\(.*\)\s*\{\s*$" -- '*.h' '*.cpp' # "{\n" on same line as "if" / "for"
git grep -nIE "\(const " -- '*.h' '*.cpp' # const on left side of type git grep -nIE "[,\(<]\s*const " -- '*.h' '*.cpp' # const on left side of type
git grep -nIE "^ [^*]|[^*] | [^*]" -- '*.h' '*.cpp' # uses spaces for indentation or mixes spaces and tabs git grep -nIE "^ [^*]|[^*] | [^*]" -- '*.h' '*.cpp' # uses spaces for indentation or mixes spaces and tabs
git grep -nIE "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" -- '*.h' '*.cpp' | egrep -v "return [&]" # right-aligned reference ampersand (needs to exclude return)
# right-aligned reference pointer star (needs to exclude return and comments)
git grep -nIE "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" -- '*.h' '*.cpp' | egrep -v "return [*]" | egrep -v "^* [*]" | egrep -v "^*//.*"
) | egrep -v "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" | egrep -v "^test/" ) | egrep -v "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" | egrep -v "^test/"
) )