Skip to content

Commit

Permalink
Useless changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed May 10, 2024
1 parent c17a3bb commit 426a51b
Showing 73 changed files with 132 additions and 309 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -132,6 +132,7 @@ Checks: [
'-bugprone-crtp-constructor-accessibility',
'-bugprone-suspicious-stringview-data-usage',
'-bugprone-multi-level-implicit-pointer-conversion',
'-cert-err33-c',

'-zircon-*'
]
2 changes: 1 addition & 1 deletion base/base/constexpr_helpers.h
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ bool func_wrapper(Func && func, Arg && arg)
template <typename T, T Begin, typename Func, T... Is>
constexpr bool static_for_impl(Func && f, std::integer_sequence<T, Is...>)
{
return (func_wrapper(std::forward<Func>(f), std::integral_constant<T, Begin + Is>{}) || ...);
return (func_wrapper(f, std::integral_constant<T, Begin + Is>{}) || ...);
}

template <auto Begin, decltype(Begin) End, typename Func>
2 changes: 1 addition & 1 deletion src/Access/Common/AccessRightsElement.cpp
Original file line number Diff line number Diff line change
@@ -245,7 +245,7 @@ bool AccessRightsElements::sameOptions() const

void AccessRightsElements::eraseNonGrantable()
{
boost::range::remove_erase_if(*this, [](AccessRightsElement & element) // NOLINT
std::erase_if(*this, [](AccessRightsElement & element)
{
element.eraseNonGrantable();
return element.empty();
10 changes: 5 additions & 5 deletions src/Access/Common/AllowedClientHosts.cpp
Original file line number Diff line number Diff line change
@@ -308,7 +308,7 @@ void AllowedClientHosts::removeAddress(const IPAddress & address)
if (address.isLoopback())
local_host = false;
else
boost::range::remove_erase(addresses, address); // NOLINT
std::erase(addresses, address);
}

void AllowedClientHosts::addSubnet(const IPSubnet & subnet)
@@ -328,7 +328,7 @@ void AllowedClientHosts::removeSubnet(const IPSubnet & subnet)
else if (subnet.isMaskAllBitsOne())
removeAddress(subnet.getPrefix());
else
boost::range::remove_erase(subnets, subnet); // NOLINT
std::erase(subnets, subnet);
}

void AllowedClientHosts::addName(const String & name)
@@ -344,7 +344,7 @@ void AllowedClientHosts::removeName(const String & name)
if (boost::iequals(name, "localhost"))
local_host = false;
else
boost::range::remove_erase(names, name); // NOLINT
std::erase(names, name);
}

void AllowedClientHosts::addNameRegexp(const String & name_regexp)
@@ -364,7 +364,7 @@ void AllowedClientHosts::removeNameRegexp(const String & name_regexp)
else if (name_regexp == ".*")
any_host = false;
else
boost::range::remove_erase(name_regexps, name_regexp); // NOLINT
std::erase(name_regexps, name_regexp);
}

void AllowedClientHosts::addLikePattern(const String & pattern)
@@ -384,7 +384,7 @@ void AllowedClientHosts::removeLikePattern(const String & pattern)
else if ((pattern == "%") || (pattern == "0.0.0.0/0") || (pattern == "::/0"))
any_host = false;
else
boost::range::remove_erase(like_patterns, pattern); // NOLINT
std::erase(like_patterns, pattern);
}

void AllowedClientHosts::addLocalHost()
2 changes: 1 addition & 1 deletion src/Access/IAccessStorage.cpp
Original file line number Diff line number Diff line change
@@ -583,7 +583,7 @@ void IAccessStorage::backup(BackupEntriesCollector & backup_entries_collector, c
throwBackupNotAllowed();

auto entities = readAllWithIDs(type);
boost::range::remove_erase_if(entities, [](const std::pair<UUID, AccessEntityPtr> & x) { return !x.second->isBackupAllowed(); }); // NOLINT
std::erase_if(entities, [](const std::pair<UUID, AccessEntityPtr> & x) { return !x.second->isBackupAllowed(); });

if (entities.empty())
return;
2 changes: 1 addition & 1 deletion src/Access/ReplicatedAccessStorage.cpp
Original file line number Diff line number Diff line change
@@ -654,7 +654,7 @@ void ReplicatedAccessStorage::backup(BackupEntriesCollector & backup_entries_col
throwBackupNotAllowed();

auto entities = readAllWithIDs(type);
boost::range::remove_erase_if(entities, [](const std::pair<UUID, AccessEntityPtr> & x) { return !x.second->isBackupAllowed(); }); // NOLINT
std::erase_if(entities, [](const std::pair<UUID, AccessEntityPtr> & x) { return !x.second->isBackupAllowed(); });

if (entities.empty())
return;
4 changes: 2 additions & 2 deletions src/Access/SettingsConstraints.cpp
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ void SettingsConstraints::check(const Settings & current_settings, const Setting

void SettingsConstraints::check(const Settings & current_settings, SettingsChanges & changes, SettingSource source) const
{
boost::range::remove_erase_if( // NOLINT
std::erase_if(
changes,
[&](SettingChange & change) -> bool
{
@@ -211,7 +211,7 @@ void SettingsConstraints::check(const MergeTreeSettings & current_settings, cons

void SettingsConstraints::clamp(const Settings & current_settings, SettingsChanges & changes, SettingSource source) const
{
boost::range::remove_erase_if( // NOLINT
std::erase_if(
changes,
[&](SettingChange & change) -> bool
{
3 changes: 1 addition & 2 deletions src/Analyzer/Passes/QueryAnalysisPass.cpp
Original file line number Diff line number Diff line change
@@ -1284,8 +1284,7 @@ class QueryAnalyzer
resolved_identifier->formatASTForErrorMessage(),
join_node.formatASTForErrorMessage());
}
if (table_side)
result = *table_side;
result = table_side;
}
return result;
}
4 changes: 2 additions & 2 deletions src/Analyzer/QueryTreePassManager.cpp
Original file line number Diff line number Diff line change
@@ -85,9 +85,9 @@ class ValidationChecker : public InDepthQueryTreeVisitor<ValidationChecker>
void visitImpl(QueryTreeNodePtr & node) const
{
if (auto * column = node->as<ColumnNode>())
return visitColumn(column);
visitColumn(column);
else if (auto * function = node->as<FunctionNode>())
return visitFunction(function);
visitFunction(function);
}
private:
void visitColumn(ColumnNode * column) const
2 changes: 1 addition & 1 deletion src/BridgeHelper/XDBCBridgeHelper.h
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ class XDBCBridgeHelper : public IXDBCBridgeHelper
if (character.length() > 1)
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Failed to parse quoting style from '{}' for service {}",
character, BridgeHelperMixin::serviceAlias());
else if (character.length() == 0)
else if (character.empty())
quote_style = IdentifierQuotingStyle::None;
else if (character[0] == '`')
quote_style = IdentifierQuotingStyle::Backticks;
4 changes: 2 additions & 2 deletions src/Client/ClientBase.cpp
Original file line number Diff line number Diff line change
@@ -273,7 +273,7 @@ class QueryInterruptHandler : private boost::noncopyable
static void start(Int32 signals_before_stop = 1) { exit_after_signals.store(signals_before_stop); }

/// Set value not greater then 0 to mark the query as stopped.
static void stop() { return exit_after_signals.store(0); }
static void stop() { exit_after_signals.store(0); }

/// Return true if the query was stopped.
/// Query was stopped if it received at least "signals_before_stop" interrupt signals.
@@ -2812,7 +2812,7 @@ class OptionsAliasParser
*/
std::pair<std::string, std::string> operator()(const std::string& token) const
{
if (token.find("--") != 0)
if (token.starts_with("--"))
return {};
std::string arg = token.substr(2);

4 changes: 2 additions & 2 deletions src/Columns/ColumnSparse.cpp
Original file line number Diff line number Diff line change
@@ -577,7 +577,7 @@ void ColumnSparse::getPermutation(IColumn::PermutationSortDirection direction, I
return;
}

return getPermutationImpl(direction, stability, limit, null_direction_hint, res, nullptr);
getPermutationImpl(direction, stability, limit, null_direction_hint, res, nullptr);
}

void ColumnSparse::updatePermutation(IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability,
@@ -590,7 +590,7 @@ void ColumnSparse::updatePermutation(IColumn::PermutationSortDirection direction
void ColumnSparse::getPermutationWithCollation(const Collator & collator, IColumn::PermutationSortDirection direction, IColumn::PermutationSortStability stability,
size_t limit, int null_direction_hint, Permutation & res) const
{
return getPermutationImpl(direction, stability, limit, null_direction_hint, res, &collator);
getPermutationImpl(direction, stability, limit, null_direction_hint, res, &collator);
}

void ColumnSparse::updatePermutationWithCollation(
4 changes: 2 additions & 2 deletions src/Common/MortonUtils.h
Original file line number Diff line number Diff line change
@@ -100,9 +100,9 @@ void intervalBinaryPartition(UInt64 first, UInt64 last, F && callback)
chassert(split >= first);
chassert(split <= last);

intervalBinaryPartition(first, split, std::forward<F>(callback));
intervalBinaryPartition(first, split, callback);
if (split < last)
intervalBinaryPartition(split + 1, last, std::forward<F>(callback));
intervalBinaryPartition(split + 1, last, callback);
}


2 changes: 1 addition & 1 deletion src/Common/NetException.h
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ class NetException : public Exception
public:
template <typename T>
requires std::is_convertible_v<T, String>
NetException(int code, T && message) : Exception(std::forward<T>(message), code)
NetException(int code, T && message) : Exception(message, code)
{
message_format_string = tryGetStaticFormatString(message);
}
5 changes: 2 additions & 3 deletions src/Formats/JSONUtils.cpp
Original file line number Diff line number Diff line change
@@ -192,12 +192,12 @@ namespace JSONUtils

void skipRowForJSONEachRow(ReadBuffer & in)
{
return skipRowForJSONEachRowImpl<'{', '}'>(in);
skipRowForJSONEachRowImpl<'{', '}'>(in);
}

void skipRowForJSONCompactEachRow(ReadBuffer & in)
{
return skipRowForJSONEachRowImpl<'[', ']'>(in);
skipRowForJSONEachRowImpl<'[', ']'>(in);
}

NamesAndTypesList readRowAndGetNamesAndDataTypesForJSONEachRow(ReadBuffer & in, const FormatSettings & settings, JSONInferenceInfo * inference_info)
@@ -235,7 +235,6 @@ namespace JSONUtils
skipWhitespaceIfAny(in);
bool first = true;
DataTypes types;
String field;
while (!in.eof() && *in.position() != ']')
{
if (!first)
2 changes: 1 addition & 1 deletion src/Functions/FunctionsExternalDictionaries.h
Original file line number Diff line number Diff line change
@@ -1356,7 +1356,7 @@ class FunctionDictGetDescendantsOverloadResolverImpl final : public IFunctionOve
"Illegal type of third argument of function {}. Expected const unsigned integer.",
getName());

auto value = static_cast<Int64>(arguments[2].column->getInt(0));
Int64 value = arguments[2].column->getInt(0);
if (value < 0)
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type of third argument of function {}. Expected const unsigned integer.",
2 changes: 1 addition & 1 deletion src/Interpreters/Access/InterpreterGrantQuery.cpp
Original file line number Diff line number Diff line change
@@ -255,7 +255,7 @@ namespace
if (roles_to_revoke.all)
boost::range::set_difference(all_granted_roles_set, roles_to_revoke.except_ids, std::back_inserter(roles_to_revoke_ids));
else
boost::range::remove_erase_if(roles_to_revoke_ids, [&](const UUID & id) { return !all_granted_roles_set.count(id); });
std::erase_if(roles_to_revoke_ids, [&](const UUID & id) { return !all_granted_roles_set.count(id); });

roles_to_revoke = roles_to_revoke_ids;
current_user_access.checkAdminOption(roles_to_revoke_ids);
2 changes: 1 addition & 1 deletion src/Interpreters/ActionsDAG.cpp
Original file line number Diff line number Diff line change
@@ -589,7 +589,7 @@ void ActionsDAG::removeUnusedActions(const std::unordered_set<const Node *> & us
}
}

nodes.remove_if([&](const Node & node) { return !visited_nodes.contains(&node); });
std::erase_if(nodes, [&](const Node & node) { return !visited_nodes.contains(&node); });
std::erase_if(inputs, [&](const Node * node) { return !visited_nodes.contains(node); });
}

8 changes: 3 additions & 5 deletions src/Interpreters/Aggregator.cpp
Original file line number Diff line number Diff line change
@@ -1803,10 +1803,8 @@ void Aggregator::writeToTemporaryFileImpl(
size_t block_size_rows = block.rows();
size_t block_size_bytes = block.bytes();

if (block_size_rows > max_temporary_block_size_rows)
max_temporary_block_size_rows = block_size_rows;
if (block_size_bytes > max_temporary_block_size_bytes)
max_temporary_block_size_bytes = block_size_bytes;
max_temporary_block_size_rows = std::max(block_size_rows, max_temporary_block_size_rows);
max_temporary_block_size_bytes = std::max(block_size_bytes, max_temporary_block_size_bytes);
};

for (UInt32 bucket = 0; bucket < Method::Data::NUM_BUCKETS; ++bucket)
@@ -3160,7 +3158,7 @@ void Aggregator::mergeBlocks(BucketToBlocks bucket_to_blocks, AggregatedDataVari
result.aggregates_pools.push_back(std::make_shared<Arena>());
Arena * aggregates_pool = result.aggregates_pools.back().get();

auto task = [group = CurrentThread::getGroup(), bucket, &merge_bucket, aggregates_pool]{ return merge_bucket(bucket, aggregates_pool, group); };
auto task = [group = CurrentThread::getGroup(), bucket, &merge_bucket, aggregates_pool]{ merge_bucket(bucket, aggregates_pool, group); };

if (thread_pool)
thread_pool->scheduleOrThrowOnError(task);
2 changes: 1 addition & 1 deletion src/Interpreters/Cache/FileCache.cpp
Original file line number Diff line number Diff line change
@@ -1074,7 +1074,7 @@ void FileCache::freeSpaceRatioKeepingThreadFunc()

void FileCache::iterate(IterateFunc && func, const UserID & user_id)
{
return metadata.iterate([&](const LockedKey & locked_key)
metadata.iterate([&](const LockedKey & locked_key)
{
for (const auto & file_segment_metadata : locked_key)
func(FileSegment::getInfo(file_segment_metadata.second->file_segment));
4 changes: 2 additions & 2 deletions src/Interpreters/Cluster.cpp
Original file line number Diff line number Diff line change
@@ -392,10 +392,10 @@ Cluster::Cluster(const Poco::Util::AbstractConfiguration & config,
config_prefix += ".";

secret = config.getString(config_prefix + "secret", "");
boost::range::remove_erase(config_keys, "secret");
std::erase(config_keys, "secret");

allow_distributed_ddl_queries = config.getBool(config_prefix + "allow_distributed_ddl_queries", true);
boost::range::remove_erase(config_keys, "allow_distributed_ddl_queries");
std::erase(config_keys, "allow_distributed_ddl_queries");

if (config_keys.empty())
throw Exception(ErrorCodes::SHARD_HAS_NO_CONNECTIONS, "No cluster elements (shard, node) specified in config at path {}", config_prefix);
16 changes: 8 additions & 8 deletions src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
@@ -1394,18 +1394,18 @@ void Context::checkAccessImpl(const Args &... args) const
return getAccess()->checkAccess(args...);
}

void Context::checkAccess(const AccessFlags & flags) const { return checkAccessImpl(flags); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database) const { return checkAccessImpl(flags, database); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table) const { return checkAccessImpl(flags, database, table); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, std::string_view column) const { return checkAccessImpl(flags, database, table, column); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, const std::vector<std::string_view> & columns) const { return checkAccessImpl(flags, database, table, columns); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, const Strings & columns) const { return checkAccessImpl(flags, database, table, columns); }
void Context::checkAccess(const AccessFlags & flags) const { checkAccessImpl(flags); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database) const { checkAccessImpl(flags, database); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table) const { checkAccessImpl(flags, database, table); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, std::string_view column) const { checkAccessImpl(flags, database, table, column); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, const std::vector<std::string_view> & columns) const { checkAccessImpl(flags, database, table, columns); }
void Context::checkAccess(const AccessFlags & flags, std::string_view database, std::string_view table, const Strings & columns) const { checkAccessImpl(flags, database, table, columns); }
void Context::checkAccess(const AccessFlags & flags, const StorageID & table_id) const { checkAccessImpl(flags, table_id.getDatabaseName(), table_id.getTableName()); }
void Context::checkAccess(const AccessFlags & flags, const StorageID & table_id, std::string_view column) const { checkAccessImpl(flags, table_id.getDatabaseName(), table_id.getTableName(), column); }
void Context::checkAccess(const AccessFlags & flags, const StorageID & table_id, const std::vector<std::string_view> & columns) const { checkAccessImpl(flags, table_id.getDatabaseName(), table_id.getTableName(), columns); }
void Context::checkAccess(const AccessFlags & flags, const StorageID & table_id, const Strings & columns) const { checkAccessImpl(flags, table_id.getDatabaseName(), table_id.getTableName(), columns); }
void Context::checkAccess(const AccessRightsElement & element) const { return checkAccessImpl(element); }
void Context::checkAccess(const AccessRightsElements & elements) const { return checkAccessImpl(elements); }
void Context::checkAccess(const AccessRightsElement & element) const { checkAccessImpl(element); }
void Context::checkAccess(const AccessRightsElements & elements) const { checkAccessImpl(elements); }

std::shared_ptr<const ContextAccess> Context::getAccess() const
{
1 change: 0 additions & 1 deletion src/Interpreters/DDLWorker.cpp
Original file line number Diff line number Diff line change
@@ -922,7 +922,6 @@ void DDLWorker::cleanupQueue(Int64, const ZooKeeperPtr & zookeeper)
String node_path = fs::path(queue_dir) / node_name;

Coordination::Stat stat;
String dummy;

try
{
2 changes: 1 addition & 1 deletion src/Interpreters/DatabaseCatalog.cpp
Original file line number Diff line number Diff line change
@@ -1438,7 +1438,7 @@ void DatabaseCatalog::checkTableCanBeRemovedOrRenamed(
if (!check_referential_dependencies && !check_loading_dependencies)
return;
std::lock_guard lock{databases_mutex};
return checkTableCanBeRemovedOrRenamedUnlocked(table_id, check_referential_dependencies, check_loading_dependencies, is_drop_database);
checkTableCanBeRemovedOrRenamedUnlocked(table_id, check_referential_dependencies, check_loading_dependencies, is_drop_database);
}

void DatabaseCatalog::checkTableCanBeRemovedOrRenamedUnlocked(
4 changes: 2 additions & 2 deletions src/Interpreters/ExpressionAnalyzer.cpp
Original file line number Diff line number Diff line change
@@ -336,7 +336,7 @@ void ExpressionAnalyzer::analyzeAggregation(ActionsDAGPtr & temp_actions)
/// But don't remove last key column if no aggregate functions, otherwise aggregation will not work.
if (!aggregate_descriptions.empty() || group_size > 1)
{
if (j + 1 < static_cast<ssize_t>(group_size))
if (j + 1 < group_size)
group_elements_ast[j] = std::move(group_elements_ast.back());

group_elements_ast.pop_back();
@@ -390,7 +390,7 @@ void ExpressionAnalyzer::analyzeAggregation(ActionsDAGPtr & temp_actions)
/// But don't remove last key column if no aggregate functions, otherwise aggregation will not work.
if (!aggregate_descriptions.empty() || size > 1)
{
if (i + 1 < static_cast<ssize_t>(size))
if (i + 1 < size)
group_asts[i] = std::move(group_asts.back());

group_asts.pop_back();
4 changes: 4 additions & 0 deletions src/Interpreters/GinFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// NOLINTBEGIN(clang-analyzer-optin.core.EnumCastOutOfRange)

#include <Columns/ColumnArray.h>
#include <Columns/ColumnLowCardinality.h>
#include <Columns/ColumnNullable.h>
@@ -174,3 +176,5 @@ bool GinFilter::match(const GinPostingsCache & postings_cache) const
}

}

// NOLINTEND(clang-analyzer-optin.core.EnumCastOutOfRange)
2 changes: 1 addition & 1 deletion src/Interpreters/GraceHashJoin.cpp
Original file line number Diff line number Diff line change
@@ -415,7 +415,7 @@ void GraceHashJoin::addBuckets(const size_t bucket_count)
void GraceHashJoin::checkTypesOfKeys(const Block & block) const
{
chassert(hash_join);
return hash_join->checkTypesOfKeys(block);
hash_join->checkTypesOfKeys(block);
}

void GraceHashJoin::initialize(const Block & sample_block)
6 changes: 1 addition & 5 deletions src/Interpreters/IExternalLoadable.cpp
Original file line number Diff line number Diff line change
@@ -22,12 +22,8 @@ UInt64 calculateDurationWithBackoff(pcg64 & rnd_engine, size_t error_count)
constexpr UInt64 backoff_initial_sec = 5;
constexpr UInt64 backoff_max_sec = 10 * 60; /// 10 minutes

if (error_count < 1)
error_count = 1;

/// max seconds is 600 and 2 ** 10 == 1024
if (error_count > 11)
error_count = 11;
error_count = std::clamp<size_t>(error_count, 1, 11);

std::uniform_int_distribution<UInt64> distribution(0, static_cast<UInt64>(std::exp2(error_count - 1)));
return std::min<UInt64>(backoff_max_sec, backoff_initial_sec + distribution(rnd_engine));
Loading
Oops, something went wrong.

0 comments on commit 426a51b

Please sign in to comment.