mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Stylecheck script fails on MacOS #13492
- Install GNU grep on macOS with brew install grep - Use GNU grep with -E option - The following errors fixed. ``` $scripts/check_style.sh ggrep: warning: stray \ before / ggrep: warning: stray \ before / ggrep: warning: * at start of expression ggrep: warning: * at start of expression ``` Fixes [Stylecheck script fails on MacOS #13492](https://github.com/ethereum/solidity/issues/13492)
This commit is contained in:
parent
25fc3aa32f
commit
1596af5248
@ -582,7 +582,7 @@ void ControlFlowBuilder::operator()(yul::FunctionCall const& _functionCall)
|
||||
solAssert(m_currentNode && m_inlineAssembly, "");
|
||||
yul::ASTWalker::operator()(_functionCall);
|
||||
|
||||
if (auto const *builtinFunction = m_inlineAssembly->dialect().builtin(_functionCall.functionName.name))
|
||||
if (auto const* builtinFunction = m_inlineAssembly->dialect().builtin(_functionCall.functionName.name))
|
||||
{
|
||||
if (builtinFunction->controlFlowSideEffects.canTerminate)
|
||||
connect(m_currentNode, m_transactionReturnNode);
|
||||
|
@ -152,7 +152,7 @@ private:
|
||||
|
||||
CFGNode* newLabel();
|
||||
CFGNode* createLabelHere();
|
||||
void placeAndConnectLabel(CFGNode *_node);
|
||||
void placeAndConnectLabel(CFGNode* _node);
|
||||
|
||||
CFG::NodeContainer& m_nodeContainer;
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const&
|
||||
{
|
||||
bool isLocalOrReturn = false;
|
||||
if (auto const* identifier = dynamic_cast<Identifier const*>(&_expression))
|
||||
if (auto const *variableDeclaration = dynamic_cast<VariableDeclaration const*>(identifier->annotation().referencedDeclaration))
|
||||
if (auto const* variableDeclaration = dynamic_cast<VariableDeclaration const*>(identifier->annotation().referencedDeclaration))
|
||||
if (variableDeclaration->isLocalOrReturn())
|
||||
isLocalOrReturn = true;
|
||||
if (!isLocalOrReturn)
|
||||
|
@ -373,7 +373,7 @@ private:
|
||||
/// Stack of current visited AST nodes, used for location attachment
|
||||
std::stack<ASTNode const*> m_visitedNodes;
|
||||
/// The runtime context if in Creation mode, this is used for generating tags that would be stored into the storage and then used at runtime.
|
||||
CompilerContext *m_runtimeContext;
|
||||
CompilerContext* m_runtimeContext;
|
||||
/// The index of the runtime subroutine.
|
||||
size_t m_runtimeSub = std::numeric_limits<size_t>::max();
|
||||
/// An index of low-level function labels by name.
|
||||
|
@ -2231,7 +2231,7 @@ bool ExpressionCompiler::visit(IndexRangeAccess const& _indexAccess)
|
||||
|
||||
Type const& baseType = *_indexAccess.baseExpression().annotation().type;
|
||||
|
||||
ArrayType const *arrayType = dynamic_cast<ArrayType const*>(&baseType);
|
||||
ArrayType const* arrayType = dynamic_cast<ArrayType const*>(&baseType);
|
||||
if (!arrayType)
|
||||
if (ArraySliceType const* sliceType = dynamic_cast<ArraySliceType const*>(&baseType))
|
||||
arrayType = &sliceType->arrayType();
|
||||
|
@ -347,7 +347,7 @@ void StackLayoutGenerator::processEntryPoint(CFG::BasicBlock const& _entry, CFG:
|
||||
// entry layout of the backwards jump target as the initial exit layout of the backwards-jumping block.
|
||||
while (!toVisit.empty())
|
||||
{
|
||||
CFG::BasicBlock const *block = *toVisit.begin();
|
||||
CFG::BasicBlock const* block = *toVisit.begin();
|
||||
toVisit.pop_front();
|
||||
|
||||
if (visited.count(block))
|
||||
|
@ -4,6 +4,16 @@ set -eu
|
||||
|
||||
ERROR_LOG="$(mktemp -t check_style_XXXXXX.log)"
|
||||
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
if ! command -v ggrep &> /dev/null
|
||||
then
|
||||
brew install grep # install GNU grep on macOS
|
||||
fi
|
||||
grepCommand="ggrep"
|
||||
else
|
||||
grepCommand="grep"
|
||||
fi
|
||||
|
||||
EXCLUDE_FILES=(
|
||||
# The line below is left unquoted to allow the shell globbing path expansion
|
||||
test/cmdlineTests/*/{err,output}
|
||||
@ -40,7 +50,7 @@ REPO_ROOT="$(dirname "$0")"/..
|
||||
cd "$REPO_ROOT" || exit 1
|
||||
|
||||
WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" |
|
||||
grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}" || true
|
||||
${grepCommand} -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}" || true
|
||||
)
|
||||
|
||||
if [[ "$WHITESPACE" != "" ]]
|
||||
@ -53,30 +63,30 @@ fi
|
||||
|
||||
function preparedGrep
|
||||
{
|
||||
git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "${EXCLUDE_FILES_JOINED}"
|
||||
git grep -nIE "$1" -- '*.h' '*.cpp' | ${grepCommand} -v "${EXCLUDE_FILES_JOINED}"
|
||||
return $?
|
||||
}
|
||||
|
||||
FORMATERROR=$(
|
||||
(
|
||||
preparedGrep "#include \"" | grep -E -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters
|
||||
preparedGrep "#include \"" | ${grepCommand} -E -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters
|
||||
preparedGrep "\<(if|for|while|switch)\(" # no space after "if", "for", "while" or "switch"
|
||||
preparedGrep "\<for\>\s*\([^=]*\>\s:\s.*\)" # no space before range based for-loop
|
||||
preparedGrep "\<if\>\s*\(.*\)\s*\{\s*$" # "{\n" on same line as "if"
|
||||
preparedGrep "\<for\>[[:space:]]*\([^=]*\>[[:space:]]:[[:space:]].*\)" # no space before range based for-loop
|
||||
preparedGrep "\<if\>[[:space:]]*\(.*\)[[:space:]]*\{[[:space:]]*$" # "{\n" on same line as "if"
|
||||
preparedGrep "namespace .*\{"
|
||||
preparedGrep "[,\(<]\s*const " # const on left side of type
|
||||
preparedGrep "^\s*(static)?\s*const " # const on left side of type (beginning of line)
|
||||
preparedGrep "[,\(<][[:space:]]*const " # const on left side of type
|
||||
preparedGrep "^[[:space:]]*(static)?[[:space:]]*const " # const on left side of type (beginning of line)
|
||||
preparedGrep "^ [^*]|[^*] | [^*]" # uses spaces for indentation or mixes spaces and tabs
|
||||
preparedGrep "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" | grep -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return)
|
||||
preparedGrep "[a-zA-Z0-9_][[:space:]]*[&][a-zA-Z_]" | ${grepCommand} -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return)
|
||||
# right-aligned reference pointer star (needs to exclude return and comments)
|
||||
preparedGrep "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" | grep -E -v -e "return [*]" -e "^* [*]" -e "^*//.*"
|
||||
preparedGrep "[a-zA-Z0-9_][[:space:]]*[*][a-zA-Z_]" | ${grepCommand} -E -v -e "return [*]" -e ":[[:space:]]*[*]" -e ".*//.*"
|
||||
# unqualified move()/forward() checks, i.e. make sure that std::move() and std::forward() are used instead of move() and forward()
|
||||
preparedGrep "move\(.+\)" | grep -v "std::move" | grep -E "[^a-z]move"
|
||||
preparedGrep "forward\(.+\)" | grep -v "std::forward" | grep -E "[^a-z]forward"
|
||||
preparedGrep "move\(.+\)" | ${grepCommand} -v "std::move" | ${grepCommand} -E "[^a-z]move"
|
||||
preparedGrep "forward\(.+\)" | ${grepCommand} -v "std::forward" | ${grepCommand} -E "[^a-z]forward"
|
||||
# make sure `using namespace std` is not used in INCLUDE_DIRECTORIES
|
||||
# shellcheck disable=SC2068,SC2068
|
||||
grep -nIE -d skip "using namespace std;" ${NAMESPACE_STD_FREE_FILES[@]}
|
||||
) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true
|
||||
${grepCommand} -nIE -d skip "using namespace std;" ${NAMESPACE_STD_FREE_FILES[@]}
|
||||
) | ${grepCommand} -E -v -e "^[a-zA-Z\./]*:[0-9]*:[[:space:]]*/(/|\*)" -e "^test/" || true
|
||||
)
|
||||
|
||||
if [[ "$FORMATERROR" != "" ]]
|
||||
|
Loading…
Reference in New Issue
Block a user