From 8ca6715e1807ed95d8e4afea071886231ffcb709 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 14 Feb 2019 11:37:24 +0100 Subject: [PATCH 1/3] More style checks. --- libdevcore/CommonData.h | 2 +- liblangutil/ErrorReporter.cpp | 2 +- liblangutil/Exceptions.cpp | 2 +- libsolidity/codegen/CompilerUtils.cpp | 2 +- libsolidity/codegen/ContractCompiler.cpp | 2 +- libsolidity/codegen/LValue.cpp | 2 +- libsolidity/formal/SymbolicVariables.cpp | 4 ++-- libsolidity/interface/Natspec.cpp | 2 +- libsolidity/interface/Natspec.h | 2 +- libyul/optimiser/StructuralSimplifier.h | 4 ++-- scripts/check_style.sh | 5 ++++- 11 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index adf9d70ce..ec3d014d9 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -240,7 +240,7 @@ bool contains(T const& _t, V const& _v) /// place at the end, but already visited elements might be invalidated. /// If nothing is replaced, no copy is performed. template -void iterateReplacing(std::vector& _vector, const F& _f) +void iterateReplacing(std::vector& _vector, F const& _f) { // Concept: _f must be Callable, must accept param T&, must return optional> bool useModified = false; diff --git a/liblangutil/ErrorReporter.cpp b/liblangutil/ErrorReporter.cpp index 5b6e0072f..fb01847d5 100644 --- a/liblangutil/ErrorReporter.cpp +++ b/liblangutil/ErrorReporter.cpp @@ -134,7 +134,7 @@ void ErrorReporter::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::Type::DeclarationError, diff --git a/liblangutil/Exceptions.cpp b/liblangutil/Exceptions.cpp index 346313d5e..4e68dfa5b 100644 --- a/liblangutil/Exceptions.cpp +++ b/liblangutil/Exceptions.cpp @@ -57,7 +57,7 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip *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) { if (!_location.isEmpty()) diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index f8c8b3a88..e19e452ba 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -653,7 +653,7 @@ void CompilerUtils::convertType( bool chopSignBitsPending = _chopSignBits && targetTypeCategory == Type::Category::Integer; if (chopSignBitsPending) { - const IntegerType& targetIntegerType = dynamic_cast(_targetType); + const IntegerType& targetIntegerType = dynamic_cast(_targetType); chopSignBitsPending = targetIntegerType.isSigned(); } diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index c3e37f4d2..31342816c 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -355,7 +355,7 @@ bool hasPayableFunctions(ContractDefinition const& _contract) void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contract) { map, FunctionTypePointer> interfaceFunctions = _contract.interfaceFunctions(); - map, const eth::AssemblyItem> callDataUnpackerEntryPoints; + map, eth::AssemblyItem const> callDataUnpackerEntryPoints; if (_contract.isLibrary()) { diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 70dbee812..d3fe4e439 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -473,7 +473,7 @@ void StorageByteArrayElement::setToZero(SourceLocation const&, bool _removeRefer 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()), m_arrayType(_arrayType) { diff --git a/libsolidity/formal/SymbolicVariables.cpp b/libsolidity/formal/SymbolicVariables.cpp index c4fc81da8..57921558c 100644 --- a/libsolidity/formal/SymbolicVariables.cpp +++ b/libsolidity/formal/SymbolicVariables.cpp @@ -65,7 +65,7 @@ smt::Expression SymbolicVariable::increaseIndex() SymbolicBoolVariable::SymbolicBoolVariable( TypePointer _type, string const& _uniqueName, - smt::SolverInterface&_interface + smt::SolverInterface& _interface ): SymbolicVariable(move(_type), _uniqueName, _interface) { @@ -102,7 +102,7 @@ SymbolicFixedBytesVariable::SymbolicFixedBytesVariable( SymbolicFunctionVariable::SymbolicFunctionVariable( TypePointer _type, string const& _uniqueName, - smt::SolverInterface&_interface + smt::SolverInterface& _interface ): SymbolicVariable(move(_type), _uniqueName, _interface), m_declaration(m_interface.newVariable(currentName(), smtSort(*m_type))) diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 27aa07388..e28d8703e 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -118,7 +118,7 @@ string Natspec::extractDoc(multimap const& _tags, string const& return value; } -Json::Value Natspec::devDocumentation(std::multimap const &_tags) +Json::Value Natspec::devDocumentation(std::multimap const& _tags) { Json::Value json(Json::objectValue); auto dev = extractDoc(_tags, "dev"); diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index fbaa6d4da..7a0c40a1a 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -59,7 +59,7 @@ private: /// @param _tags docTags that are used. /// @return A JSON representation /// of the contract's developer documentation - static Json::Value devDocumentation(std::multimap const &_tags); + static Json::Value devDocumentation(std::multimap const& _tags); }; } //solidity NS diff --git a/libyul/optimiser/StructuralSimplifier.h b/libyul/optimiser/StructuralSimplifier.h index d68a96206..111c7fdc7 100644 --- a/libyul/optimiser/StructuralSimplifier.h +++ b/libyul/optimiser/StructuralSimplifier.h @@ -44,8 +44,8 @@ public: void operator()(Block& _block) override; private: void simplify(std::vector& _statements); - bool expressionAlwaysTrue(Expression const &_expression); - bool expressionAlwaysFalse(Expression const &_expression); + bool expressionAlwaysTrue(Expression const& _expression); + bool expressionAlwaysFalse(Expression const& _expression); }; } diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 09d5825ee..f24f79973 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -19,8 +19,11 @@ FORMATERROR=$( ( git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' # no space after "if" or "for" git grep -nIE "\\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 "[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/" ) From 809b9a95f96f58c6af29243d3d502f6deefbaa36 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 14 Feb 2019 11:53:00 +0100 Subject: [PATCH 2/3] Even more style checks. --- libdevcore/Common.h | 4 ++-- libdevcore/Exceptions.h | 2 +- libdevcore/Keccak256.cpp | 10 +++++----- libdevcore/StringUtils.h | 4 ++-- libevmasm/CommonSubexpressionEliminator.h | 2 +- libevmasm/Instruction.cpp | 4 ++-- liblangutil/ErrorReporter.h | 4 ++-- liblangutil/Token.cpp | 2 +- liblll/CodeFragment.h | 2 +- liblll/CompilerState.cpp | 2 +- libsolidity/analysis/DocStringAnalyser.cpp | 6 +++--- libsolidity/ast/ExperimentalFeatures.h | 4 ++-- libsolidity/codegen/CompilerUtils.cpp | 12 ++++++------ libsolidity/codegen/CompilerUtils.h | 10 +++++----- scripts/check_style.sh | 1 + 15 files changed, 35 insertions(+), 34 deletions(-) diff --git a/libdevcore/Common.h b/libdevcore/Common.h index ac2993608..35574909c 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -74,7 +74,7 @@ using strings = std::vector; /// Interprets @a _u as a two's complement signed number and returns the resulting s256. inline s256 u2s(u256 _u) { - static const bigint c_end = bigint(1) << 256; + static bigint const c_end = bigint(1) << 256; if (boost::multiprecision::bit_test(_u, 255)) return s256(-(c_end - _u)); else @@ -84,7 +84,7 @@ inline s256 u2s(u256 _u) /// @returns the two's complement signed representation of the signed number _u. inline u256 s2u(s256 _u) { - static const bigint c_end = bigint(1) << 256; + static bigint const c_end = bigint(1) << 256; if (_u >= 0) return u256(_u); else diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index cfe72fbf6..dc4cadd36 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -31,7 +31,7 @@ namespace dev /// Base class for all exceptions. struct Exception: virtual std::exception, virtual boost::exception { - const char* what() const noexcept override; + char const* what() const noexcept override; /// @returns "FileName:LineNumber" referring to the point where the exception was thrown. std::string lineInfo() const; diff --git a/libdevcore/Keccak256.cpp b/libdevcore/Keccak256.cpp index 6afca3a13..752973822 100644 --- a/libdevcore/Keccak256.cpp +++ b/libdevcore/Keccak256.cpp @@ -47,17 +47,17 @@ namespace /******** The Keccak-f[1600] permutation ********/ /*** Constants. ***/ -static const uint8_t rho[24] = \ +static uint8_t const rho[24] = \ { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44}; -static const uint8_t pi[24] = \ +static uint8_t const pi[24] = \ {10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1}; -static const uint64_t RC[24] = \ +static uint64_t const RC[24] = \ {1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, 0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL, @@ -118,7 +118,7 @@ static inline void keccakf(void* state) { _(for (size_t i = 0; i < L; i += ST) { S; }) #define mkapply_ds(NAME, S) \ static inline void NAME(uint8_t* dst, \ - const uint8_t* src, \ + uint8_t const* src, \ size_t len) { \ FOR(i, 1, len, S); \ } @@ -148,7 +148,7 @@ mkapply_sd(setout, dst[i] = src[i]) // setout inline void hash( uint8_t* out, size_t outlen, - const uint8_t* in, + uint8_t const* in, size_t inlen, size_t rate, uint8_t delim diff --git a/libdevcore/StringUtils.h b/libdevcore/StringUtils.h index 64044cb2b..16c2fb158 100644 --- a/libdevcore/StringUtils.h +++ b/libdevcore/StringUtils.h @@ -139,8 +139,8 @@ inline std::string formatNumberReadable( if (len < 24) return str; - const int initialChars = (prefix == HexPrefix::Add) ? 6 : 4; - const int finalChars = 4; + int const initialChars = (prefix == HexPrefix::Add) ? 6 : 4; + int const finalChars = 4; int numSkipped = len - initialChars - finalChars; return str.substr(0, initialChars) + diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h index eba25db08..a09b1913f 100644 --- a/libevmasm/CommonSubexpressionEliminator.h +++ b/libevmasm/CommonSubexpressionEliminator.h @@ -149,7 +149,7 @@ private: /// Appends the given assembly item. void appendItem(AssemblyItem const& _item); - static const int c_invalidPosition = -0x7fffffff; + static int const c_invalidPosition = -0x7fffffff; AssemblyItems m_generatedItems; /// Current height of the stack relative to the start. diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index cf98c9384..b3ee0fe50 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -29,7 +29,7 @@ using namespace std; using namespace dev; using namespace dev::solidity; -const std::map dev::solidity::c_instructions = +std::map const dev::solidity::c_instructions = { { "STOP", Instruction::STOP }, { "ADD", Instruction::ADD }, @@ -173,7 +173,7 @@ const std::map dev::solidity::c_instructions = { "SELFDESTRUCT", Instruction::SELFDESTRUCT } }; -static const std::map c_instructionInfo = +static std::map const c_instructionInfo = { // Add, Args, Ret, SideEffects, GasPriceTier { Instruction::STOP, { "STOP", 0, 0, 0, true, Tier::Zero } }, { Instruction::ADD, { "ADD", 0, 2, 1, false, Tier::VeryLow } }, diff --git a/liblangutil/ErrorReporter.h b/liblangutil/ErrorReporter.h index fe4321ce5..fe0e92277 100644 --- a/liblangutil/ErrorReporter.h +++ b/liblangutil/ErrorReporter.h @@ -119,8 +119,8 @@ private: unsigned m_errorCount = 0; unsigned m_warningCount = 0; - const unsigned c_maxWarningsAllowed = 256; - const unsigned c_maxErrorsAllowed = 256; + unsigned const c_maxWarningsAllowed = 256; + unsigned const c_maxErrorsAllowed = 256; }; } diff --git a/liblangutil/Token.cpp b/liblangutil/Token.cpp index cbfd4a8ca..b03fa3185 100644 --- a/liblangutil/Token.cpp +++ b/liblangutil/Token.cpp @@ -143,7 +143,7 @@ static Token keywordByName(string const& _name) // and keywords to be put inside the keywords variable. #define KEYWORD(name, string, precedence) {string, Token::name}, #define TOKEN(name, string, precedence) - static const map keywords({TOKEN_LIST(TOKEN, KEYWORD)}); + static map const keywords({TOKEN_LIST(TOKEN, KEYWORD)}); #undef KEYWORD #undef TOKEN auto it = keywords.find(_name); diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h index 5c2f49a69..f59a5d6fd 100644 --- a/liblll/CodeFragment.h +++ b/liblll/CodeFragment.h @@ -65,7 +65,7 @@ private: ReadCallback m_readFile; }; -static const CodeFragment NullCodeFragment; +static CodeFragment const NullCodeFragment; } } diff --git a/liblll/CompilerState.cpp b/liblll/CompilerState.cpp index 019582d4c..dbd6e91cd 100644 --- a/liblll/CompilerState.cpp +++ b/liblll/CompilerState.cpp @@ -44,7 +44,7 @@ CodeFragment const& CompilerState::getDef(std::string const& _s) const void CompilerState::populateStandard() { - static const string s = "{" + static string const s = "{" "(def 'panic () (asm INVALID))" // Alternative macro version of alloc, which is currently implemented in the parser // "(def 'alloc (n) (raw (msize) (when n (pop (mload (+ (msize) (& (- n 1) (~ 0x1f))))))))" diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index 83409290b..108a18564 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -42,7 +42,7 @@ bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit) bool DocStringAnalyser::visit(ContractDefinition const& _contract) { - static const set validTags = set{"author", "title", "dev", "notice"}; + static set const validTags = set{"author", "title", "dev", "notice"}; parseDocStrings(_contract, _contract.annotation(), validTags, "contracts"); return true; @@ -99,7 +99,7 @@ void DocStringAnalyser::handleConstructor( DocumentedAnnotation& _annotation ) { - static const set validTags = set{"author", "dev", "notice", "param"}; + static set const validTags = set{"author", "dev", "notice", "param"}; parseDocStrings(_node, _annotation, validTags, "constructor"); checkParameters(_callable, _annotation); } @@ -110,7 +110,7 @@ void DocStringAnalyser::handleCallable( DocumentedAnnotation& _annotation ) { - static const set validTags = set{"author", "dev", "notice", "return", "param"}; + static set const validTags = set{"author", "dev", "notice", "return", "param"}; parseDocStrings(_node, _annotation, validTags, "functions"); checkParameters(_callable, _annotation); } diff --git a/libsolidity/ast/ExperimentalFeatures.h b/libsolidity/ast/ExperimentalFeatures.h index 54aad573c..1d94ae67f 100644 --- a/libsolidity/ast/ExperimentalFeatures.h +++ b/libsolidity/ast/ExperimentalFeatures.h @@ -35,13 +35,13 @@ enum class ExperimentalFeature TestOnlyAnalysis }; -static const std::map ExperimentalFeatureOnlyAnalysis = +static std::map const ExperimentalFeatureOnlyAnalysis = { { ExperimentalFeature::SMTChecker, true }, { ExperimentalFeature::TestOnlyAnalysis, true }, }; -static const std::map ExperimentalFeatureNames = +static std::map const ExperimentalFeatureNames = { { "ABIEncoderV2", ExperimentalFeature::ABIEncoderV2 }, { "SMTChecker", ExperimentalFeature::SMTChecker }, diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index e19e452ba..10896feaa 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -37,11 +37,11 @@ namespace dev namespace solidity { -const unsigned CompilerUtils::dataStartOffset = 4; -const size_t CompilerUtils::freeMemoryPointer = 64; -const size_t CompilerUtils::zeroPointer = CompilerUtils::freeMemoryPointer + 32; -const size_t CompilerUtils::generalPurposeMemoryStart = CompilerUtils::zeroPointer + 32; -const unsigned CompilerUtils::identityContractAddress = 4; +unsigned const CompilerUtils::dataStartOffset = 4; +size_t const CompilerUtils::freeMemoryPointer = 64; +size_t const CompilerUtils::zeroPointer = CompilerUtils::freeMemoryPointer + 32; +size_t const CompilerUtils::generalPurposeMemoryStart = CompilerUtils::zeroPointer + 32; +unsigned const CompilerUtils::identityContractAddress = 4; static_assert(CompilerUtils::freeMemoryPointer >= 64, "Free memory pointer must not overlap with scratch area."); static_assert(CompilerUtils::zeroPointer >= CompilerUtils::freeMemoryPointer + 32, "Zero pointer must not overlap with free memory pointer."); @@ -653,7 +653,7 @@ void CompilerUtils::convertType( bool chopSignBitsPending = _chopSignBits && targetTypeCategory == Type::Category::Integer; if (chopSignBitsPending) { - const IntegerType& targetIntegerType = dynamic_cast(_targetType); + IntegerType const& targetIntegerType = dynamic_cast(_targetType); chopSignBitsPending = targetIntegerType.isSigned(); } diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index d095e05f9..97b53bcf2 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -273,18 +273,18 @@ public: /// Bytes we need to the start of call data. /// - The size in bytes of the function (hash) identifier. - static const unsigned dataStartOffset; + static unsigned const dataStartOffset; /// Position of the free-memory-pointer in memory; - static const size_t freeMemoryPointer; + static size_t const freeMemoryPointer; /// Position of the memory slot that is always zero. - static const size_t zeroPointer; + static size_t const zeroPointer; /// Starting offset for memory available to the user (aka the contract). - static const size_t generalPurposeMemoryStart; + static size_t const generalPurposeMemoryStart; private: /// Address of the precompiled identity contract. - static const unsigned identityContractAddress; + static unsigned const identityContractAddress; /// Stores the given string in memory. /// Stack pre: mempos diff --git a/scripts/check_style.sh b/scripts/check_style.sh index f24f79973..2a645107b 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -20,6 +20,7 @@ FORMATERROR=$( git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' # no space after "if" or "for" git grep -nIE "\\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 + git grep -nIE "^\s*(static)?\s*const " -- '*.h' '*.cpp' # const on left side of type (beginning of line) 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) From 8d7ccff1c0b4781faf05401f743e30d31a76924e Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 14 Feb 2019 11:54:52 +0100 Subject: [PATCH 3/3] Improve style of style check script. --- scripts/check_style.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 2a645107b..01e50662a 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -24,8 +24,8 @@ FORMATERROR=$( 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/" + git grep -nIE "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" -- '*.h' '*.cpp' | egrep -v -e "return [*]" -e "^* [*]" -e "^*//.*" +) | egrep -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" ) if [[ "$FORMATERROR" != "" ]]