Style check for abbreviations

This commit is contained in:
Alexey Milovidov 2024-02-17 02:14:15 +01:00
parent 509d8ee99c
commit 2f315e0eb5
19 changed files with 41 additions and 38 deletions

View File

@ -125,7 +125,7 @@ ConnectionParameters::ConnectionParameters(const Poco::Util::AbstractConfigurati
Poco::Timespan(config.getInt("send_timeout", DBMS_DEFAULT_SEND_TIMEOUT_SEC), 0))
.withReceiveTimeout(
Poco::Timespan(config.getInt("receive_timeout", DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC), 0))
.withTcpKeepAliveTimeout(
.withTCPKeepAliveTimeout(
Poco::Timespan(config.getInt("tcp_keep_alive_timeout", DEFAULT_TCP_KEEP_ALIVE_TIMEOUT), 0))
.withHandshakeTimeout(
Poco::Timespan(config.getInt("handshake_timeout_ms", DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC * 1000) * 1000))

View File

@ -227,7 +227,7 @@ void parseMatchNode(UInt64 parent_id, UInt64 & id, const YAML::Node & node, Resu
if (!match.contains(key_name))
{
throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "Yaml match rule must contain key {}", key_name);
throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "YAML match rule must contain key {}", key_name);
}
for (const auto & [key, node_] : match)
{

View File

@ -51,12 +51,12 @@ namespace
};
class FunctionTcpPort : public FunctionConstantBase<FunctionTcpPort, UInt16, DataTypeUInt16>
class FunctionTCPPort : public FunctionConstantBase<FunctionTCPPort, UInt16, DataTypeUInt16>
{
public:
static constexpr auto name = "tcpPort";
static FunctionPtr create(ContextPtr context) { return std::make_shared<FunctionTcpPort>(context); }
explicit FunctionTcpPort(ContextPtr context) : FunctionConstantBase(context->getTCPPort(), context->isDistributed()) {}
static FunctionPtr create(ContextPtr context) { return std::make_shared<FunctionTCPPort>(context); }
explicit FunctionTCPPort(ContextPtr context) : FunctionConstantBase(context->getTCPPort(), context->isDistributed()) {}
};
@ -153,9 +153,9 @@ REGISTER_FUNCTION(ServerUUID)
factory.registerFunction<FunctionServerUUID>();
}
REGISTER_FUNCTION(TcpPort)
REGISTER_FUNCTION(TCPPort)
{
factory.registerFunction<FunctionTcpPort>();
factory.registerFunction<FunctionTCPPort>();
}
REGISTER_FUNCTION(Timezone)

View File

@ -20,7 +20,7 @@ ConnectionTimeouts ConnectionTimeouts::getTCPTimeoutsWithoutFailover(const Setti
.withConnectionTimeout(settings.connect_timeout)
.withSendTimeout(settings.send_timeout)
.withReceiveTimeout(settings.receive_timeout)
.withTcpKeepAliveTimeout(settings.tcp_keep_alive_timeout)
.withTCPKeepAliveTimeout(settings.tcp_keep_alive_timeout)
.withHandshakeTimeout(settings.handshake_timeout_ms)
.withHedgedConnectionTimeout(settings.hedged_connection_timeout_ms)
.withReceiveDataTimeout(settings.receive_data_timeout_ms);
@ -40,8 +40,8 @@ ConnectionTimeouts ConnectionTimeouts::getHTTPTimeouts(const Settings & settings
.withConnectionTimeout(settings.http_connection_timeout)
.withSendTimeout(settings.http_send_timeout)
.withReceiveTimeout(settings.http_receive_timeout)
.withHttpKeepAliveTimeout(http_keep_alive_timeout)
.withTcpKeepAliveTimeout(settings.tcp_keep_alive_timeout)
.withHTTPKeepAliveTimeout(http_keep_alive_timeout)
.withTCPKeepAliveTimeout(settings.tcp_keep_alive_timeout)
.withHandshakeTimeout(settings.handshake_timeout_ms);
}

View File

@ -16,8 +16,8 @@ struct Settings;
M(secure_connection_timeout, withSecureConnectionTimeout) \
M(send_timeout, withSendTimeout) \
M(receive_timeout, withReceiveTimeout) \
M(tcp_keep_alive_timeout, withTcpKeepAliveTimeout) \
M(http_keep_alive_timeout, withHttpKeepAliveTimeout) \
M(tcp_keep_alive_timeout, withTCPKeepAliveTimeout) \
M(http_keep_alive_timeout, withHTTPKeepAliveTimeout) \
M(hedged_connection_timeout, withHedgedConnectionTimeout) \
M(receive_data_timeout, withReceiveDataTimeout) \
M(handshake_timeout, withHandshakeTimeout) \

View File

@ -22,7 +22,6 @@ namespace ErrorCodes
# include <aws/core/utils/UUID.h>
# include <aws/core/http/HttpClientFactory.h>
# include <IO/S3/PocoHTTPClientFactory.h>
# include <aws/core/utils/HashingUtils.h>
# include <aws/core/platform/FileSystem.h>
@ -31,9 +30,7 @@ namespace ErrorCodes
# include <IO/S3/Client.h>
# include <fstream>
# include <base/EnumReflection.h>
# include <boost/algorithm/string.hpp>
# include <boost/algorithm/string/split.hpp>
# include <boost/algorithm/string/classification.hpp>
# include <Poco/Exception.h>
@ -755,7 +752,7 @@ S3CredentialsProviderChain::S3CredentialsProviderChain(
configuration.put_request_throttler,
Aws::Http::SchemeMapper::ToString(Aws::Http::Scheme::HTTP));
/// See MakeDefaultHttpResourceClientConfiguration().
/// See MakeDefaultHTTPResourceClientConfiguration().
/// This is part of EC2 metadata client, but unfortunately it can't be accessed from outside
/// of contrib/aws/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp
aws_client_configuration.maxConnections = 2;

View File

@ -146,9 +146,9 @@ ConnectionTimeouts getTimeoutsFromConfiguration(const PocoHTTPClientConfiguratio
.withConnectionTimeout(Poco::Timespan(client_configuration.connectTimeoutMs * 1000))
.withSendTimeout(Poco::Timespan(client_configuration.requestTimeoutMs * 1000))
.withReceiveTimeout(Poco::Timespan(client_configuration.requestTimeoutMs * 1000))
.withTcpKeepAliveTimeout(Poco::Timespan(
.withTCPKeepAliveTimeout(Poco::Timespan(
client_configuration.enableTcpKeepAlive ? client_configuration.tcpKeepAliveIntervalMs * 1000 : 0))
.withHttpKeepAliveTimeout(Poco::Timespan(
.withHTTPKeepAliveTimeout(Poco::Timespan(
client_configuration.http_keep_alive_timeout_ms * 1000)); /// flag indicating whether keep-alive is enabled is set to each session upon creation
}

View File

@ -4513,7 +4513,7 @@ void Context::setClientConnectionId(uint32_t connection_id_)
client_info.connection_id = connection_id_;
}
void Context::setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer)
void Context::setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer)
{
client_info.http_method = http_method;
client_info.http_user_agent = http_user_agent;

View File

@ -630,7 +630,7 @@ public:
void setClientInterface(ClientInfo::Interface interface);
void setClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version);
void setClientConnectionId(uint32_t connection_id);
void setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer);
void setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer);
void setForwardedFor(const String & forwarded_for);
void setQueryKind(ClientInfo::QueryKind query_kind);
void setQueryKindInitial();

View File

@ -25,13 +25,13 @@ String InterpreterShowFunctionsQuery::getRewrittenQuery()
const auto & query = query_ptr->as<ASTShowFunctionsQuery &>();
DatabasePtr systemDb = DatabaseCatalog::instance().getSystemDatabase();
DatabasePtr system_db = DatabaseCatalog::instance().getSystemDatabase();
String rewritten_query = fmt::format(
R"(
SELECT *
FROM {}.{})",
systemDb->getDatabaseName(),
system_db->getDatabaseName(),
functions_table);
if (!query.like.empty())

View File

@ -429,11 +429,11 @@ void Session::setClientConnectionId(uint32_t connection_id)
prepared_client_info->connection_id = connection_id;
}
void Session::setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer)
void Session::setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer)
{
if (session_context)
{
session_context->setHttpClientInfo(http_method, http_user_agent, http_referer);
session_context->setHTTPClientInfo(http_method, http_user_agent, http_referer);
}
else
{

View File

@ -65,7 +65,7 @@ public:
void setClientInterface(ClientInfo::Interface interface);
void setClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version);
void setClientConnectionId(uint32_t connection_id);
void setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer);
void setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer);
void setForwardedFor(const String & forwarded_for);
void setQuotaClientKey(const String & quota_key);
void setConnectionClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version);

View File

@ -359,7 +359,7 @@ std::unique_ptr<IParserKQLFunction> KQLFunctionFactory::get(String & kql_functio
return std::make_unique<ExtractAll>();
case KQLFunctionValue::extract_json:
return std::make_unique<ExtractJson>();
return std::make_unique<ExtractJSON>();
case KQLFunctionValue::has_any_index:
return std::make_unique<HasAnyIndex>();
@ -389,7 +389,7 @@ std::unique_ptr<IParserKQLFunction> KQLFunctionFactory::get(String & kql_functio
return std::make_unique<ParseCSV>();
case KQLFunctionValue::parse_json:
return std::make_unique<ParseJson>();
return std::make_unique<ParseJSON>();
case KQLFunctionValue::parse_url:
return std::make_unique<ParseURL>();

View File

@ -240,7 +240,7 @@ bool ExtractAll::convertImpl(String & out, IParser::Pos & pos)
return true;
}
bool ExtractJson::convertImpl(String & out, IParser::Pos & pos)
bool ExtractJSON::convertImpl(String & out, IParser::Pos & pos)
{
String datatype = "String";
ParserKeyword s_kql("typeof");
@ -431,7 +431,7 @@ bool ParseCSV::convertImpl(String & out, IParser::Pos & pos)
return true;
}
bool ParseJson::convertImpl(String & out, IParser::Pos & pos)
bool ParseJSON::convertImpl(String & out, IParser::Pos & pos)
{
const String fn_name = getKQLFunctionName(pos);
if (fn_name.empty())

View File

@ -62,7 +62,7 @@ protected:
bool convertImpl(String & out, IParser::Pos & pos) override;
};
class ExtractJson : public IParserKQLFunction
class ExtractJSON : public IParserKQLFunction
{
protected:
const char * getName() const override { return "extract_json(), extractjson()"; }
@ -125,7 +125,7 @@ protected:
bool convertImpl(String & out, IParser::Pos & pos) override;
};
class ParseJson : public IParserKQLFunction
class ParseJJSON : public IParserKQLFunction
{
protected:
const char * getName() const override { return "parse_json()"; }

View File

@ -212,7 +212,7 @@ static AvroDeserializer::DeserializeFn createDecimalDeserializeFn(const avro::No
};
}
static std::string nodeToJson(avro::NodePtr root_node)
static std::string nodeToJSON(avro::NodePtr root_node)
{
std::ostringstream ss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
ss.exceptions(std::ios::failbit);
@ -641,7 +641,7 @@ AvroDeserializer::DeserializeFn AvroDeserializer::createDeserializeFn(const avro
throw Exception(ErrorCodes::ILLEGAL_COLUMN,
"Type {} is not compatible with Avro {}:\n{}",
target_type->getName(), avro::toString(root_node->type()), nodeToJson(root_node));
target_type->getName(), avro::toString(root_node->type()), nodeToJSON(root_node));
}
AvroDeserializer::SkipFn AvroDeserializer::createSkipFn(const avro::NodePtr & root_node)

View File

@ -125,7 +125,7 @@ namespace ErrorCodes
namespace
{
bool tryAddHttpOptionHeadersFromConfig(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config)
bool tryAddHTTPOptionHeadersFromConfig(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config)
{
if (config.has("http_options_response"))
{
@ -153,7 +153,7 @@ bool tryAddHttpOptionHeadersFromConfig(HTTPServerResponse & response, const Poco
void processOptionsRequest(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config)
{
/// If can add some headers from config
if (tryAddHttpOptionHeadersFromConfig(response, config))
if (tryAddHTTPOptionHeadersFromConfig(response, config))
{
response.setKeepAlive(false);
response.setStatusAndReason(HTTPResponse::HTTP_NO_CONTENT);
@ -496,7 +496,7 @@ bool HTTPHandler::authenticateUser(
else if (request.getMethod() == HTTPServerRequest::HTTP_POST)
http_method = ClientInfo::HTTPMethod::POST;
session->setHttpClientInfo(http_method, request.get("User-Agent", ""), request.get("Referer", ""));
session->setHTTPClientInfo(http_method, request.get("User-Agent", ""), request.get("Referer", ""));
session->setForwardedFor(request.get("X-Forwarded-For", ""));
session->setQuotaClientKey(quota_key);
@ -1065,7 +1065,7 @@ void HTTPHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse
response.set("X-ClickHouse-Server-Display-Name", server_display_name);
if (!request.get("Origin", "").empty())
tryAddHttpOptionHeadersFromConfig(response, server.config());
tryAddHTTPOptionHeadersFromConfig(response, server.config());
/// For keep-alive to work.
if (request.getVersion() == HTTPServerRequest::HTTP_1_1)

View File

@ -1511,7 +1511,7 @@ void StorageURL::processNamedCollectionResult(Configuration & configuration, con
&& configuration.http_method != Poco::Net::HTTPRequest::HTTP_PUT)
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"Http method can be POST or PUT (current: {}). For insert default is POST, for select GET",
"HTTP method can be POST or PUT (current: {}). For insert default is POST, for select GET",
configuration.http_method);
configuration.format = collection.getOrDefault<String>("format", "auto");

View File

@ -442,3 +442,9 @@ ls -1d $ROOT_PATH/contrib/*-cmake | xargs -I@ find @ -name 'CMakeLists.txt' -or
# DOS/Windows newlines
find $ROOT_PATH/{base,src,programs,utils,docs} -name '*.md' -or -name '*.h' -or -name '*.cpp' -or -name '*.js' -or -name '*.py' -or -name '*.html' | xargs grep -l -P '\r$' && echo "^ Files contain DOS/Windows newlines (\r\n instead of \n)."
# Wrong spelling of abbreviations, e.g. SQL is right, Sql is wrong. XMLHttpRequest is very wrong.
find $ROOT_PATH/{src,base,programs,utils} -name '*.h' -or -name '*.cpp' |
grep -vP $EXCLUDE_DIRS |
xargs grep -P 'Sql|Html|Xml|Cpu|Tcp|Udp|Http|Db|Json|Yaml' | grep -v -P 'RabbitMQ|Azure|Aws|aws|Avro|IO/S3' &&
echo "Abbreviations such as SQL, XML, HTTP, should be in all caps. For example, SQL is right, Sql is wrong. XMLHttpRequest is very wrong."