Applied readability-magic-numbers clang-tidy fixes
This commit is contained in:
@@ -18,6 +18,7 @@ Checks: >-
|
|||||||
-google-readability-todo,
|
-google-readability-todo,
|
||||||
-google-default-arguments,
|
-google-default-arguments,
|
||||||
-google-explicit-constructor,
|
-google-explicit-constructor,
|
||||||
|
-google-build-using-namespace,
|
||||||
-hicpp-signed-bitwise,
|
-hicpp-signed-bitwise,
|
||||||
-hicpp-explicit-conversions,
|
-hicpp-explicit-conversions,
|
||||||
-llvmlibc-*,
|
-llvmlibc-*,
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
|||||||
{
|
{
|
||||||
namespace plantuml_common = clanguml::common::generators::plantuml;
|
namespace plantuml_common = clanguml::common::generators::plantuml;
|
||||||
|
|
||||||
|
constexpr auto kAbbreviatedMethodArgumentsLength{15};
|
||||||
|
|
||||||
const auto &uns = m_config.using_namespace();
|
const auto &uns = m_config.using_namespace();
|
||||||
|
|
||||||
std::string class_type{"class"};
|
std::string class_type{"class"};
|
||||||
@@ -148,7 +150,8 @@ void generator::generate(const class_ &c, std::ostream &ostr) const
|
|||||||
auto args_string = fmt::format("{}", fmt::join(params, ", "));
|
auto args_string = fmt::format("{}", fmt::join(params, ", "));
|
||||||
if (m_config.generate_method_arguments() ==
|
if (m_config.generate_method_arguments() ==
|
||||||
config::method_arguments::abbreviated) {
|
config::method_arguments::abbreviated) {
|
||||||
args_string = clanguml::util::abbreviate(args_string, 10);
|
args_string = clanguml::util::abbreviate(
|
||||||
|
args_string, kAbbreviatedMethodArgumentsLength);
|
||||||
}
|
}
|
||||||
ostr << args_string;
|
ostr << args_string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ template <> struct hash<clanguml::common::model::namespace_> {
|
|||||||
|
|
||||||
std::size_t seed = key.size();
|
std::size_t seed = key.size();
|
||||||
for (const auto &ns : key) {
|
for (const auto &ns : key) {
|
||||||
seed ^= std::hash<std::string>{}(ns) + 0x6a3712b5 + (seed << 6) +
|
seed ^=
|
||||||
(seed >> 2);
|
std::hash<std::string>{}(ns) + clanguml::util::hash_seed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return seed;
|
return seed;
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ template <> struct hash<clanguml::common::model::filesystem_path> {
|
|||||||
|
|
||||||
std::size_t seed = key.size();
|
std::size_t seed = key.size();
|
||||||
for (const auto &ns : key) {
|
for (const auto &ns : key) {
|
||||||
seed ^= std::hash<std::string>{}(ns) + 0x6a3712b5 + (seed << 6) +
|
seed ^=
|
||||||
(seed >> 2);
|
std::hash<std::string>{}(ns) + clanguml::util::hash_seed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return seed;
|
return seed;
|
||||||
|
|||||||
@@ -403,11 +403,14 @@ bool ensure_output_directory_exists(const std::string &dir)
|
|||||||
|
|
||||||
void print_version()
|
void print_version()
|
||||||
{
|
{
|
||||||
|
constexpr auto kLLVMBackendPackageStringLength{5};
|
||||||
std::cout << "clang-uml " << clanguml::version::CLANG_UML_VERSION << '\n';
|
std::cout << "clang-uml " << clanguml::version::CLANG_UML_VERSION << '\n';
|
||||||
std::cout << "Copyright (C) 2021-2022 Bartek Kryza <bkryza@gmail.com>"
|
std::cout << "Copyright (C) 2021-2022 Bartek Kryza <bkryza@gmail.com>"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
std::cout << "Built with LLVM version: "
|
std::cout << "Built with LLVM version: "
|
||||||
<< std::string{BACKEND_PACKAGE_STRING}.substr(5) << std::endl;
|
<< std::string{BACKEND_PACKAGE_STRING}.substr(
|
||||||
|
kLLVMBackendPackageStringLength)
|
||||||
|
<< std::endl;
|
||||||
std::cout << "Using LLVM version: " << clang::getClangFullVersion()
|
std::cout << "Using LLVM version: " << clang::getClangFullVersion()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,13 +193,16 @@ std::string function::full_name_no_ns() const
|
|||||||
|
|
||||||
std::string function::message_name(message_render_mode mode) const
|
std::string function::message_name(message_render_mode mode) const
|
||||||
{
|
{
|
||||||
|
constexpr auto kAbbreviatedMethodArgumentsLength{15};
|
||||||
|
|
||||||
if (mode == message_render_mode::no_arguments) {
|
if (mode == message_render_mode::no_arguments) {
|
||||||
return fmt::format("{}(){}", name(), is_const() ? " const" : "");
|
return fmt::format("{}(){}", name(), is_const() ? " const" : "");
|
||||||
}
|
}
|
||||||
else if (mode == message_render_mode::abbreviated) {
|
else if (mode == message_render_mode::abbreviated) {
|
||||||
return fmt::format("{}({}){}", name(),
|
return fmt::format("{}({}){}", name(),
|
||||||
clanguml::util::abbreviate(
|
clanguml::util::abbreviate(
|
||||||
fmt::format("{}", fmt::join(parameters_, ",")), 15),
|
fmt::format("{}", fmt::join(parameters_, ",")),
|
||||||
|
kAbbreviatedMethodArgumentsLength),
|
||||||
is_const() ? " const" : "");
|
is_const() ? " const" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +262,8 @@ std::string method::full_name(bool /*relative*/) const
|
|||||||
|
|
||||||
std::string method::message_name(message_render_mode mode) const
|
std::string method::message_name(message_render_mode mode) const
|
||||||
{
|
{
|
||||||
|
constexpr auto kAbbreviatedMethodArgumentsLength{15};
|
||||||
|
|
||||||
const std::string style = is_static() ? "__" : "";
|
const std::string style = is_static() ? "__" : "";
|
||||||
|
|
||||||
if (mode == message_render_mode::no_arguments) {
|
if (mode == message_render_mode::no_arguments) {
|
||||||
@@ -268,7 +273,8 @@ std::string method::message_name(message_render_mode mode) const
|
|||||||
else if (mode == message_render_mode::abbreviated) {
|
else if (mode == message_render_mode::abbreviated) {
|
||||||
return fmt::format("{}({}){}", name(),
|
return fmt::format("{}({}){}", name(),
|
||||||
clanguml::util::abbreviate(
|
clanguml::util::abbreviate(
|
||||||
fmt::format("{}", fmt::join(parameters(), ",")), 15),
|
fmt::format("{}", fmt::join(parameters(), ",")),
|
||||||
|
kAbbreviatedMethodArgumentsLength),
|
||||||
is_const() ? " const" : "");
|
is_const() ? " const" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +340,8 @@ std::string function_template::full_name_no_ns() const
|
|||||||
|
|
||||||
std::string function_template::message_name(message_render_mode mode) const
|
std::string function_template::message_name(message_render_mode mode) const
|
||||||
{
|
{
|
||||||
|
constexpr auto kAbbreviatedMethodArgumentsLength{15};
|
||||||
|
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
render_template_params(s, using_namespace(), true);
|
render_template_params(s, using_namespace(), true);
|
||||||
std::string template_params = s.str();
|
std::string template_params = s.str();
|
||||||
@@ -345,7 +353,8 @@ std::string function_template::message_name(message_render_mode mode) const
|
|||||||
else if (mode == message_render_mode::abbreviated) {
|
else if (mode == message_render_mode::abbreviated) {
|
||||||
return fmt::format("{}({}){}", name(),
|
return fmt::format("{}({}){}", name(),
|
||||||
clanguml::util::abbreviate(
|
clanguml::util::abbreviate(
|
||||||
fmt::format("{}", fmt::join(parameters(), ",")), 15),
|
fmt::format("{}", fmt::join(parameters(), ",")),
|
||||||
|
kAbbreviatedMethodArgumentsLength),
|
||||||
is_const() ? " const" : "");
|
is_const() ? " const" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,4 +281,13 @@ template <> bool ends_with(const std::string &value, const std::string &suffix)
|
|||||||
return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin());
|
return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t hash_seed(std::size_t seed)
|
||||||
|
{
|
||||||
|
constexpr auto kSeedStart{0x6a3712b5};
|
||||||
|
constexpr auto kSeedShiftFirst{6};
|
||||||
|
constexpr auto kSeedShiftSecond{2};
|
||||||
|
|
||||||
|
return kSeedStart + (seed << kSeedShiftFirst) + (seed >> kSeedShiftSecond);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace clanguml::util
|
} // namespace clanguml::util
|
||||||
|
|||||||
@@ -27,8 +27,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace clanguml {
|
namespace clanguml::util {
|
||||||
namespace util {
|
|
||||||
|
|
||||||
std::string ltrim(const std::string &s);
|
std::string ltrim(const std::string &s);
|
||||||
std::string rtrim(const std::string &s);
|
std::string rtrim(const std::string &s);
|
||||||
@@ -247,5 +246,6 @@ void for_each_if(const T &collection, C &&cond, F &&func)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace util
|
std::size_t hash_seed(std::size_t seed);
|
||||||
} // namespace clanguml
|
|
||||||
|
} // namespace clanguml::util
|
||||||
Reference in New Issue
Block a user