Skip to content

Commit

Permalink
Add clang-tidy identifier naming rules (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomagdy committed Mar 24, 2020
1 parent 6ac045c commit a4b8f45
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 165 deletions.
24 changes: 24 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,29 @@ CheckOptions:
value: '1'
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: readability-identifier-naming.ClassCase
value: 'lower_case'
- key: readability-identifier-naming.StructCase
value: 'lower_case'
- key: readability-identifier-naming.StructCase
value: 'lower_case'
- key: readability-identifier-naming.ParameterCase
value: 'lower_case'
- key: readability-identifier-naming.PrivateMemberCase
value: 'lower_case'
- key: readability-identifier-naming.LocalVariableCase
value: 'lower_case'
- key: readability-identifier-naming.TypeAliasCase
value: 'lower_case'
- key: readability-identifier-naming.UnionCase
value: 'lower_case'
- key: readability-identifier-naming.FunctionCase
value: 'lower_case'
- key: readability-identifier-naming.NamespaceCase
value: 'lower_case'
- key: readability-identifier-naming.GlobalConstantCase
value: 'UPPER_CASE'
- key: readability-identifier-naming.PrivateMemberPrefix
value: 'm_'

...
18 changes: 9 additions & 9 deletions include/aws/lambda-runtime/outcome.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace lambda_runtime {
template <typename TResult, typename TFailure>
class outcome {
public:
outcome(TResult const& s) : s(s), success(true) {}
outcome(TResult const& s) : s(s), m_success(true) {}

outcome(TFailure const& f) : f(f), success(false) {}
outcome(TFailure const& f) : f(f), m_success(false) {}

outcome(outcome&& other) noexcept : success(other.success)
outcome(outcome&& other) noexcept : m_success(other.m_success)
{
if (success) {
if (m_success) {
s = std::move(other.s);
}
else {
Expand All @@ -39,7 +39,7 @@ class outcome {

~outcome()
{
if (success) {
if (m_success) {
s.~TResult();
}
else {
Expand All @@ -49,24 +49,24 @@ class outcome {

TResult const& get_result() const
{
assert(success);
assert(m_success);
return s;
}

TFailure const& get_failure() const
{
assert(!success);
assert(!m_success);
return f;
}

bool is_success() const { return success; }
bool is_success() const { return m_success; }

private:
union {
TResult s;
TFailure f;
};
bool success;
bool m_success;
};
} // namespace lambda_runtime
} // namespace aws
6 changes: 3 additions & 3 deletions src/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static size_t write_data(char* ptr, size_t size, size_t nmemb, void* userdata)
// std::isspace has a few edge cases that would trigger UB. In particular, the documentation says:
// "The behavior is undefined if the value of the input is not representable as unsigned char and is not equal to EOF."
// So, this function does the simple obvious thing instead.
static inline bool IsSpace(int ch)
static inline bool is_whitespace(int ch)
{
constexpr int space = 0x20; // space (0x20, ' ')
constexpr int form_feed = 0x0c; // form feed (0x0c, '\f')
Expand All @@ -96,9 +96,9 @@ static inline bool IsSpace(int ch)
static inline std::string trim(std::string s)
{
// trim right
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !IsSpace(ch); }).base(), s.end());
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !is_whitespace(ch); }).base(), s.end());
// trim left
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !IsSpace(ch); }));
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !is_whitespace(ch); }));
return s;
}

Expand Down
14 changes: 7 additions & 7 deletions tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <aws/core/utils/logging/ConsoleLogSystem.h>
#include "gtest/gtest.h"

std::function<std::shared_ptr<Aws::Utils::Logging::LogSystemInterface>()> GetConsoleLoggerFactory()
std::function<std::shared_ptr<Aws::Utils::Logging::LogSystemInterface>()> get_console_logger_factory()
{
return [] {
return Aws::MakeShared<Aws::Utils::Logging::ConsoleLogSystem>(
Expand All @@ -14,11 +14,11 @@ std::string aws_prefix;

void parse_args(int argc, char** argv)
{
const std::string resourcePrefixOption = "--aws_prefix=";
const std::string resource_prefix_option = "--aws_prefix=";
for (int i = 1; i < argc; i++) {
std::string arg = argv[i];
if (arg.find(resourcePrefixOption) == 0) {
aws_prefix = arg.substr(resourcePrefixOption.length()); // get whatever value after the '='
if (arg.find(resource_prefix_option) == 0) {
aws_prefix = arg.substr(resource_prefix_option.length()); // get whatever value after the '='
break;
}
}
Expand All @@ -29,10 +29,10 @@ int main(int argc, char** argv)
parse_args(argc, argv);
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Warn;
options.loggingOptions.logger_create_fn = GetConsoleLoggerFactory();
options.loggingOptions.logger_create_fn = get_console_logger_factory();
Aws::InitAPI(options);
::testing::InitGoogleTest(&argc, argv);
int exitCode = RUN_ALL_TESTS();
int exit_code = RUN_ALL_TESTS();
Aws::ShutdownAPI(options);
return exitCode;
return exit_code;
}
Loading

0 comments on commit a4b8f45

Please sign in to comment.