提交 e8b3bac5 编写于 作者: A Alexey Milovidov

clang-tidy, part 5

上级 79c6bd5a
......@@ -21,7 +21,7 @@ std::vector<XMLConfigurationPtr> ConfigPreprocessor::processConfig(
const auto path = Poco::Path(path_str);
test->setString("path", path.absolute().toString());
if (test->getString("name", "") == "")
if (test->getString("name", "").empty())
test->setString("name", path.getBaseName());
}
......
......@@ -37,9 +37,7 @@ AccessControlManager::AccessControlManager()
}
AccessControlManager::~AccessControlManager()
{
}
AccessControlManager::~AccessControlManager() = default;
void AccessControlManager::setLocalDirectory(const String & directory_path)
......
......@@ -34,8 +34,8 @@ public:
void grant(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::string_view & column);
void grant(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::vector<std::string_view> & columns);
void grant(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const Strings & columns);
void grant(const AccessRightsElement & access, std::string_view current_database = {});
void grant(const AccessRightsElements & access, std::string_view current_database = {});
void grant(const AccessRightsElement & element, std::string_view current_database = {});
void grant(const AccessRightsElements & elements, std::string_view current_database = {});
/// Revokes a specified access granted earlier on a specified database/table/column.
/// Does nothing if the specified access is not granted.
......@@ -48,8 +48,8 @@ public:
void revoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::string_view & column);
void revoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::vector<std::string_view> & columns);
void revoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const Strings & columns);
void revoke(const AccessRightsElement & access, std::string_view current_database = {});
void revoke(const AccessRightsElements & access, std::string_view current_database = {});
void revoke(const AccessRightsElement & element, std::string_view current_database = {});
void revoke(const AccessRightsElements & elements, std::string_view current_database = {});
/// Revokes a specified access granted earlier on a specified database/table/column or on lower levels.
/// The function also restricts access if it's granted on upper level.
......@@ -61,8 +61,8 @@ public:
void partialRevoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::string_view & column);
void partialRevoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::vector<std::string_view> & columns);
void partialRevoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const Strings & columns);
void partialRevoke(const AccessRightsElement & access, std::string_view current_database = {});
void partialRevoke(const AccessRightsElements & access, std::string_view current_database = {});
void partialRevoke(const AccessRightsElement & element, std::string_view current_database = {});
void partialRevoke(const AccessRightsElements & elements, std::string_view current_database = {});
/// Revokes a specified access granted earlier on a specified database/table/column or on lower levels.
/// The function also restricts access if it's granted on upper level.
......@@ -74,8 +74,8 @@ public:
void fullRevoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::string_view & column);
void fullRevoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::vector<std::string_view> & columns);
void fullRevoke(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const Strings & columns);
void fullRevoke(const AccessRightsElement & access, std::string_view current_database = {});
void fullRevoke(const AccessRightsElements & access, std::string_view current_database = {});
void fullRevoke(const AccessRightsElement & element, std::string_view current_database = {});
void fullRevoke(const AccessRightsElements & elements, std::string_view current_database = {});
/// Returns the information about all the access granted.
struct Elements
......@@ -95,8 +95,8 @@ public:
bool isGranted(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::string_view & column) const;
bool isGranted(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const std::vector<std::string_view> & columns) const;
bool isGranted(const AccessFlags & access, const std::string_view & database, const std::string_view & table, const Strings & columns) const;
bool isGranted(const AccessRightsElement & access, std::string_view current_database = {}) const;
bool isGranted(const AccessRightsElements & access, std::string_view current_database = {}) const;
bool isGranted(const AccessRightsElement & element, std::string_view current_database = {}) const;
bool isGranted(const AccessRightsElements & elements, std::string_view current_database = {}) const;
friend bool operator ==(const AccessRights & left, const AccessRights & right);
friend bool operator !=(const AccessRights & left, const AccessRights & right) { return !(left == right); }
......@@ -109,23 +109,23 @@ private:
template <typename... Args>
void grantImpl(const AccessFlags & access, const Args &... args);
void grantImpl(const AccessRightsElement & access, std::string_view current_database);
void grantImpl(const AccessRightsElements & access, std::string_view current_database);
void grantImpl(const AccessRightsElement & element, std::string_view current_database);
void grantImpl(const AccessRightsElements & elements, std::string_view current_database);
template <int mode, typename... Args>
void revokeImpl(const AccessFlags & access, const Args &... args);
template <int mode>
void revokeImpl(const AccessRightsElement & access, std::string_view current_database);
void revokeImpl(const AccessRightsElement & element, std::string_view current_database);
template <int mode>
void revokeImpl(const AccessRightsElements & access, std::string_view current_database);
void revokeImpl(const AccessRightsElements & elements, std::string_view current_database);
template <typename... Args>
bool isGrantedImpl(const AccessFlags & access, const Args &... args) const;
bool isGrantedImpl(const AccessRightsElement & access, std::string_view current_database) const;
bool isGrantedImpl(const AccessRightsElements & access, std::string_view current_database) const;
bool isGrantedImpl(const AccessRightsElement & element, std::string_view current_database) const;
bool isGrantedImpl(const AccessRightsElements & elements, std::string_view current_database) const;
template <typename... Args>
AccessFlags getAccessImpl(const Args &... args) const;
......
......@@ -128,10 +128,10 @@ private:
bool checkAccessImpl(Poco::Logger * log_, const AccessFlags & access, const Args &... args) const;
template <int mode, bool grant_option>
bool checkAccessImpl(Poco::Logger * log_, const AccessRightsElement & access) const;
bool checkAccessImpl(Poco::Logger * log_, const AccessRightsElement & element) const;
template <int mode, bool grant_option>
bool checkAccessImpl(Poco::Logger * log_, const AccessRightsElements & access) const;
bool checkAccessImpl(Poco::Logger * log_, const AccessRightsElements & elements) const;
boost::shared_ptr<const AccessRights> calculateResultAccess(bool grant_option) const;
boost::shared_ptr<const AccessRights> calculateResultAccess(bool grant_option, UInt64 readonly_, bool allow_ddl_, bool allow_introspection_) const;
......
......@@ -254,7 +254,7 @@ namespace
}
static const std::vector<std::type_index> & getAllAccessEntityTypes()
const std::vector<std::type_index> & getAllAccessEntityTypes()
{
static const std::vector<std::type_index> res = {typeid(User), typeid(Role), typeid(RowPolicy), typeid(Quota)};
return res;
......
......@@ -270,10 +270,7 @@ bool GenericRoleSet::match(const UUID & user_id, const std::vector<UUID> & enabl
bool in_except_list = std::any_of(
enabled_roles.begin(), enabled_roles.end(), [this](const UUID & enabled_role) { return except_ids.contains(enabled_role); });
if (in_except_list)
return false;
return true;
return !in_except_list;
}
......@@ -292,10 +289,7 @@ bool GenericRoleSet::match(const UUID & user_id, const boost::container::flat_se
bool in_except_list = std::any_of(
enabled_roles.begin(), enabled_roles.end(), [this](const UUID & enabled_role) { return except_ids.contains(enabled_role); });
if (in_except_list)
return false;
return true;
return !in_except_list;
}
......
......@@ -11,9 +11,6 @@ MemoryAccessStorage::MemoryAccessStorage(const String & storage_name_)
}
MemoryAccessStorage::~MemoryAccessStorage() {}
std::optional<UUID> MemoryAccessStorage::findImpl(std::type_index type, const String & name) const
{
std::lock_guard lock{mutex};
......
......@@ -14,7 +14,6 @@ class MemoryAccessStorage : public IAccessStorage
{
public:
MemoryAccessStorage(const String & storage_name_ = "memory");
~MemoryAccessStorage() override;
/// Sets all entities at once.
void setAll(const std::vector<AccessEntityPtr> & all_entities);
......
......@@ -38,11 +38,6 @@ MultipleAccessStorage::MultipleAccessStorage(
}
MultipleAccessStorage::~MultipleAccessStorage()
{
}
std::vector<UUID> MultipleAccessStorage::findMultiple(std::type_index type, const String & name) const
{
std::vector<UUID> ids;
......
......@@ -14,7 +14,6 @@ public:
using Storage = IAccessStorage;
MultipleAccessStorage(std::vector<std::unique_ptr<Storage>> nested_storages_);
~MultipleAccessStorage() override;
std::vector<UUID> findMultiple(std::type_index type, const String & name) const;
......
......@@ -170,9 +170,7 @@ QuotaContextFactory::QuotaContextFactory(const AccessControlManager & access_con
}
QuotaContextFactory::~QuotaContextFactory()
{
}
QuotaContextFactory::~QuotaContextFactory() = default;
QuotaContextPtr QuotaContextFactory::createContext(const String & user_name, const UUID & user_id, const std::vector<UUID> & enabled_roles, const Poco::Net::IPAddress & address, const String & client_key)
......
......@@ -93,7 +93,7 @@ namespace
using ConditionIndex = RowPolicy::ConditionIndex;
static constexpr size_t MAX_CONDITION_INDEX = RowPolicy::MAX_CONDITION_INDEX;
constexpr size_t MAX_CONDITION_INDEX = RowPolicy::MAX_CONDITION_INDEX;
/// Accumulates conditions from multiple row policies and joins them using the AND logical operation.
......
......@@ -339,9 +339,6 @@ UsersConfigAccessStorage::UsersConfigAccessStorage() : IAccessStorage("users.xml
}
UsersConfigAccessStorage::~UsersConfigAccessStorage() {}
void UsersConfigAccessStorage::setConfiguration(const Poco::Util::AbstractConfiguration & config)
{
std::vector<std::pair<UUID, AccessEntityPtr>> all_entities;
......
......@@ -19,7 +19,6 @@ class UsersConfigAccessStorage : public IAccessStorage
{
public:
UsersConfigAccessStorage();
~UsersConfigAccessStorage() override;
void setConfiguration(const Poco::Util::AbstractConfiguration & config);
......
......@@ -311,9 +311,9 @@ NamesToTypeNames buildDictionaryAttributesConfiguration(
{
const auto & children = dictionary_attributes->children;
NamesToTypeNames attributes_names_and_types;
for (size_t i = 0; i < children.size(); ++i)
for (const auto & child : children)
{
const ASTDictionaryAttributeDeclaration * dict_attr = children[i]->as<const ASTDictionaryAttributeDeclaration>();
const ASTDictionaryAttributeDeclaration * dict_attr = child->as<const ASTDictionaryAttributeDeclaration>();
if (!dict_attr->type)
throw Exception("Dictionary attribute must has type", ErrorCodes::INCORRECT_DICTIONARY_DEFINITION);
......
......@@ -64,7 +64,7 @@ ExpressionAction ExpressionAction::applyFunction(
const std::vector<std::string> & argument_names_,
std::string result_name_)
{
if (result_name_ == "")
if (result_name_.empty())
{
result_name_ = function_->getName() + "(";
for (size_t i = 0 ; i < argument_names_.size(); ++i)
......
......@@ -76,7 +76,7 @@ ASTPtr ASTDictionaryLayout::clone() const
void ASTDictionaryLayout::formatImpl(const FormatSettings & settings,
FormatState & state,
FormatStateStacked expected) const
FormatStateStacked frame) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "")
<< "LAYOUT"
......@@ -94,7 +94,7 @@ void ASTDictionaryLayout::formatImpl(const FormatSettings & settings,
<< (settings.hilite ? hilite_none : "")
<< " ";
parameter->second->formatImpl(settings, state, expected);
parameter->second->formatImpl(settings, state, frame);
}
settings.ostr << ")";
settings.ostr << ")";
......
......@@ -34,10 +34,10 @@ ASTIdentifier::ASTIdentifier(const String & name_, std::vector<String> && name_p
, name_parts(name_parts_)
, semantic(std::make_shared<IdentifierSemanticImpl>())
{
if (name_parts.size() && name_parts[0] == "")
if (!name_parts.empty() && name_parts[0].empty())
name_parts.erase(name_parts.begin());
if (name == "")
if (name.empty())
{
if (name_parts.size() == 2)
name = name_parts[0] + '.' + name_parts[1];
......
......@@ -315,7 +315,7 @@ void AvroSerializer::serializeRow(const Columns & columns, size_t row_num, avro:
static avro::Codec getCodec(const std::string & codec_name)
{
if (codec_name == "")
if (codec_name.empty())
{
#ifdef SNAPPY_CODEC_AVAILABLE
return avro::Codec::SNAPPY_CODEC;
......
......@@ -43,11 +43,12 @@ std::unique_ptr<IMergeTreeIndex> MergeTreeIndexFactory::get(
throw Exception(
"Unknown Index type '" + node->type->name + "'. Available index types: " +
std::accumulate(indexes.cbegin(), indexes.cend(), std::string{},
[] (auto && lft, const auto & rht) -> std::string {
if (lft == "")
return rht.first;
[] (auto && left, const auto & right) -> std::string
{
if (left.empty())
return right.first;
else
return lft + ", " + rht.first;
return left + ", " + right.first;
}),
ErrorCodes::INCORRECT_QUERY);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册