Added more style checks [#CLICKHOUSE-3]

This commit is contained in:
Alexey Milovidov 2018-11-23 21:52:00 +03:00
parent 18400ad4e5
commit dbbacf4f87
23 changed files with 26 additions and 26 deletions

View File

@ -124,9 +124,9 @@ void ODBCColumnsInfoHandler::handleRequest(Poco::Net::HTTPServerRequest & reques
auto identifier_quote = getIdentifierQuote(hdbc); auto identifier_quote = getIdentifierQuote(hdbc);
if (identifier_quote.length() == 0) if (identifier_quote.length() == 0)
settings.identifier_quoting_style = IdentifierQuotingStyle::None; settings.identifier_quoting_style = IdentifierQuotingStyle::None;
else if(identifier_quote[0] == '`') else if (identifier_quote[0] == '`')
settings.identifier_quoting_style = IdentifierQuotingStyle::Backticks; settings.identifier_quoting_style = IdentifierQuotingStyle::Backticks;
else if(identifier_quote[0] == '"') else if (identifier_quote[0] == '"')
settings.identifier_quoting_style = IdentifierQuotingStyle::DoubleQuotes; settings.identifier_quoting_style = IdentifierQuotingStyle::DoubleQuotes;
else else
throw Exception("Can not map quote identifier '" + identifier_quote + "' to IdentifierQuotingStyle value", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); throw Exception("Can not map quote identifier '" + identifier_quote + "' to IdentifierQuotingStyle value", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);

View File

@ -25,7 +25,7 @@ Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco:
#else #else
return nullptr; return nullptr;
#endif #endif
else if(uri.getPath() == "/identifier_quote") else if (uri.getPath() == "/identifier_quote")
#if USE_POCO_SQLODBC || USE_POCO_DATAODBC #if USE_POCO_SQLODBC || USE_POCO_DATAODBC
return new IdentifierQuoteHandler(keep_alive_timeout, context); return new IdentifierQuoteHandler(keep_alive_timeout, context);
#else #else

View File

@ -272,7 +272,7 @@ public:
auto hash = calcHashes(); auto hash = calcHashes();
ptr = &hash->getData()[0]; ptr = &hash->getData()[0];
UInt64 * expected = nullptr; UInt64 * expected = nullptr;
if(saved_hash_ptr.compare_exchange_strong(expected, ptr)) if (saved_hash_ptr.compare_exchange_strong(expected, ptr))
saved_hash = std::move(hash); saved_hash = std::move(hash);
else else
ptr = expected; ptr = expected;

View File

@ -278,7 +278,7 @@ void BackgroundSchedulePool::delayExecutionThreadFunction()
{ {
std::unique_lock lock(delayed_tasks_mutex); std::unique_lock lock(delayed_tasks_mutex);
while(!shutdown) while (!shutdown)
{ {
Poco::Timestamp min_time; Poco::Timestamp min_time;

View File

@ -168,7 +168,7 @@ void ExternalTablesHandler::handlePart(const Poco::Net::MessageHeader & header,
/// Write data /// Write data
data.first->readPrefix(); data.first->readPrefix();
output->writePrefix(); output->writePrefix();
while(Block block = data.first->read()) while (Block block = data.first->read())
output->write(block); output->write(block);
data.first->readSuffix(); data.first->readSuffix();
output->writeSuffix(); output->writeSuffix();

View File

@ -150,7 +150,7 @@ ColumnRawPtrs DistinctSortedBlockInputStream::getClearingColumns(const Block & b
{ {
ColumnRawPtrs clearing_hint_columns; ColumnRawPtrs clearing_hint_columns;
clearing_hint_columns.reserve(description.size()); clearing_hint_columns.reserve(description.size());
for(const auto & sort_column_description : description) for (const auto & sort_column_description : description)
{ {
const auto sort_column_ptr = block.safeGetByPosition(sort_column_description.column_number).column.get(); const auto sort_column_ptr = block.safeGetByPosition(sort_column_description.column_number).column.get();
const auto it = std::find(key_columns.cbegin(), key_columns.cend(), sort_column_ptr); const auto it = std::find(key_columns.cbegin(), key_columns.cend(), sort_column_ptr);

View File

@ -163,7 +163,7 @@ DatabaseWithOwnTablesBase::~DatabaseWithOwnTablesBase()
{ {
shutdown(); shutdown();
} }
catch(...) catch (...)
{ {
tryLogCurrentException(__PRETTY_FUNCTION__); tryLogCurrentException(__PRETTY_FUNCTION__);
} }

View File

@ -213,7 +213,7 @@ bool ExecutableDictionarySource::supportsSelectiveLoad() const
bool ExecutableDictionarySource::hasUpdateField() const bool ExecutableDictionarySource::hasUpdateField() const
{ {
if(update_field.empty()) if (update_field.empty())
return false; return false;
else else
return true; return true;

View File

@ -1238,7 +1238,7 @@ class FunctionBinaryArithmetic : public IFunction
auto column_to = ColumnAggregateFunction::create(columns[0]->getAggregateFunction()); auto column_to = ColumnAggregateFunction::create(columns[0]->getAggregateFunction());
column_to->reserve(input_rows_count); column_to->reserve(input_rows_count);
for(size_t i = 0; i < input_rows_count; ++i) for (size_t i = 0; i < input_rows_count; ++i)
{ {
column_to->insertFrom(columns[0]->getData()[i]); column_to->insertFrom(columns[0]->getData()[i]);
column_to->insertMergeFrom(columns[1]->getData()[i]); column_to->insertMergeFrom(columns[1]->getData()[i]);

View File

@ -104,7 +104,7 @@ struct ExtractRaw
} }
else else
{ {
switch(*pos) switch (*pos)
{ {
case '[': case '[':
expects_end.push_back((current_expect_end = ']')); expects_end.push_back((current_expect_end = ']'));

View File

@ -179,7 +179,7 @@ struct ArrayAndValueSourceSelectorBySink : public ArraySinkSelector<ArrayAndValu
if (array_source.isConst() && value_source.isConst()) if (array_source.isConst() && value_source.isConst())
checkTypeAndCallConcat(typeid_cast<ConstSource<ArraySource> *>(&array_source), checkTypeAndCallConcat(typeid_cast<ConstSource<ArraySource> *>(&array_source),
typeid_cast<ConstSource<ValueSource> *>(&value_source)); typeid_cast<ConstSource<ValueSource> *>(&value_source));
else if(array_source.isConst()) else if (array_source.isConst())
checkTypeAndCallConcat(typeid_cast<ConstSource<ArraySource> *>(&array_source), checkTypeAndCallConcat(typeid_cast<ConstSource<ArraySource> *>(&array_source),
typeid_cast<ValueSource *>(&value_source)); typeid_cast<ValueSource *>(&value_source));
else if (value_source.isConst()) else if (value_source.isConst())

View File

@ -324,9 +324,9 @@ void FunctionArrayIntersect::executeImpl(Block & block, const ColumnNumbers & ar
result_column = execute<DateMap, ColumnVector<DataTypeDate::FieldType>, true>(arrays, std::move(column)); result_column = execute<DateMap, ColumnVector<DataTypeDate::FieldType>, true>(arrays, std::move(column));
else if (which.isDateTime()) else if (which.isDateTime())
result_column = execute<DateTimeMap, ColumnVector<DataTypeDateTime::FieldType>, true>(arrays, std::move(column)); result_column = execute<DateTimeMap, ColumnVector<DataTypeDateTime::FieldType>, true>(arrays, std::move(column));
else if(which.isString()) else if (which.isString())
result_column = execute<StringMap, ColumnString, false>(arrays, std::move(column)); result_column = execute<StringMap, ColumnString, false>(arrays, std::move(column));
else if(which.isFixedString()) else if (which.isFixedString())
result_column = execute<StringMap, ColumnFixedString, false>(arrays, std::move(column)); result_column = execute<StringMap, ColumnFixedString, false>(arrays, std::move(column));
else else
{ {

View File

@ -350,7 +350,7 @@ public:
for (size_t i = 0; i < vec.size(); ++i) for (size_t i = 0; i < vec.size(); ++i)
{ {
for(auto & instruction : instructions) for (auto & instruction : instructions)
instruction.perform(pos, vec[i], time_zone); instruction.perform(pos, vec[i], time_zone);
dst_offsets[i] = pos - begin; dst_offsets[i] = pos - begin;

View File

@ -58,7 +58,7 @@ namespace ErrorCodes
inline char parseEscapeSequence(char c) inline char parseEscapeSequence(char c)
{ {
switch(c) switch (c)
{ {
case 'a': case 'a':
return '\a'; return '\a';

View File

@ -1150,7 +1150,7 @@ UInt128 ExpressionAction::ActionHash::operator()(const ExpressionAction & action
SipHash hash; SipHash hash;
hash.update(action.type); hash.update(action.type);
hash.update(action.is_function_compiled); hash.update(action.is_function_compiled);
switch(action.type) switch (action.type)
{ {
case ADD_COLUMN: case ADD_COLUMN:
hash.update(action.result_name); hash.update(action.result_name);

View File

@ -590,7 +590,7 @@ void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputSt
if (query.group_by_with_rollup) if (query.group_by_with_rollup)
executeRollupOrCube(pipeline, Modificator::ROLLUP); executeRollupOrCube(pipeline, Modificator::ROLLUP);
else if(query.group_by_with_cube) else if (query.group_by_with_cube)
executeRollupOrCube(pipeline, Modificator::CUBE); executeRollupOrCube(pipeline, Modificator::CUBE);
} }
else if (expressions.has_having) else if (expressions.has_having)

View File

@ -72,7 +72,7 @@ bool PredicateExpressionsOptimizer::optimizeImpl(
ASTPtr inner_predicate; ASTPtr inner_predicate;
cloneOuterPredicateForInnerPredicate(outer_predicate, projection_columns, database_and_table_with_aliases, inner_predicate); cloneOuterPredicateForInnerPredicate(outer_predicate, projection_columns, database_and_table_with_aliases, inner_predicate);
switch(optimize_kind) switch (optimize_kind)
{ {
case OptimizeKind::NONE: continue; case OptimizeKind::NONE: continue;
case OptimizeKind::PUSH_TO_WHERE: is_rewrite_subquery |= optimizeExpression(inner_predicate, subquery->where_expression, subquery); continue; case OptimizeKind::PUSH_TO_WHERE: is_rewrite_subquery |= optimizeExpression(inner_predicate, subquery->where_expression, subquery); continue;

View File

@ -192,7 +192,7 @@ public:
{ {
rollback(); rollback();
} }
catch(...) catch (...)
{ {
tryLogCurrentException("~MergeTreeData::Transaction"); tryLogCurrentException("~MergeTreeData::Transaction");
} }

View File

@ -100,7 +100,7 @@ public:
} }
trans.commit(); trans.commit();
} }
catch(...) catch (...)
{ {
trans.rollback(); trans.rollback();
throw; throw;

View File

@ -2943,7 +2943,7 @@ StorageReplicatedMergeTree::~StorageReplicatedMergeTree()
{ {
shutdown(); shutdown();
} }
catch(...) catch (...)
{ {
tryLogCurrentException(__PRETTY_FUNCTION__); tryLogCurrentException(__PRETTY_FUNCTION__);
} }

View File

@ -16,5 +16,5 @@ ROOT_PATH=$(git rev-parse --show-toplevel)
find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' | find $ROOT_PATH/dbms -name '*.h' -or -name '*.cpp' |
grep -vP 'Compiler|build' | grep -vP 'Compiler|build' |
xargs grep $@ -P '((class|struct|namespace|enum|if|for|while|else|throw|switch).*|\)(\s*const)?(\s*override)?\s*)\{$|\s$|\t|^ {1,3}[^\* ]\S|\t' xargs grep $@ -P '((class|struct|namespace|enum|if|for|while|else|throw|switch).*|\)(\s*const)?(\s*override)?\s*)\{$|\s$|\t|^ {1,3}[^\* ]\S|\t|^\s*(if|else if|for|while|catch|switch)\('
# a curly brace not in a new line, but not for the case of C++11 init or agg. initialization | trailing whitespace | number of ws not a multiple of 4, but not in the case of comment continuation | a tab character # a curly brace not in a new line, but not for the case of C++11 init or agg. initialization | trailing whitespace | number of ws not a multiple of 4, but not in the case of comment continuation | a tab character | missing whitespace after for/if/while... before opening brace