Skip to content

Commit a4b8f45

Browse files
authored
Add clang-tidy identifier naming rules (#87)
1 parent 6ac045c commit a4b8f45

File tree

6 files changed

+192
-165
lines changed

6 files changed

+192
-165
lines changed

.clang-tidy

+24
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,29 @@ CheckOptions:
1313
value: '1'
1414
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
1515
value: '1'
16+
- key: readability-identifier-naming.ClassCase
17+
value: 'lower_case'
18+
- key: readability-identifier-naming.StructCase
19+
value: 'lower_case'
20+
- key: readability-identifier-naming.StructCase
21+
value: 'lower_case'
22+
- key: readability-identifier-naming.ParameterCase
23+
value: 'lower_case'
24+
- key: readability-identifier-naming.PrivateMemberCase
25+
value: 'lower_case'
26+
- key: readability-identifier-naming.LocalVariableCase
27+
value: 'lower_case'
28+
- key: readability-identifier-naming.TypeAliasCase
29+
value: 'lower_case'
30+
- key: readability-identifier-naming.UnionCase
31+
value: 'lower_case'
32+
- key: readability-identifier-naming.FunctionCase
33+
value: 'lower_case'
34+
- key: readability-identifier-naming.NamespaceCase
35+
value: 'lower_case'
36+
- key: readability-identifier-naming.GlobalConstantCase
37+
value: 'UPPER_CASE'
38+
- key: readability-identifier-naming.PrivateMemberPrefix
39+
value: 'm_'
1640

1741
...

include/aws/lambda-runtime/outcome.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ namespace lambda_runtime {
2323
template <typename TResult, typename TFailure>
2424
class outcome {
2525
public:
26-
outcome(TResult const& s) : s(s), success(true) {}
26+
outcome(TResult const& s) : s(s), m_success(true) {}
2727

28-
outcome(TFailure const& f) : f(f), success(false) {}
28+
outcome(TFailure const& f) : f(f), m_success(false) {}
2929

30-
outcome(outcome&& other) noexcept : success(other.success)
30+
outcome(outcome&& other) noexcept : m_success(other.m_success)
3131
{
32-
if (success) {
32+
if (m_success) {
3333
s = std::move(other.s);
3434
}
3535
else {
@@ -39,7 +39,7 @@ class outcome {
3939

4040
~outcome()
4141
{
42-
if (success) {
42+
if (m_success) {
4343
s.~TResult();
4444
}
4545
else {
@@ -49,24 +49,24 @@ class outcome {
4949

5050
TResult const& get_result() const
5151
{
52-
assert(success);
52+
assert(m_success);
5353
return s;
5454
}
5555

5656
TFailure const& get_failure() const
5757
{
58-
assert(!success);
58+
assert(!m_success);
5959
return f;
6060
}
6161

62-
bool is_success() const { return success; }
62+
bool is_success() const { return m_success; }
6363

6464
private:
6565
union {
6666
TResult s;
6767
TFailure f;
6868
};
69-
bool success;
69+
bool m_success;
7070
};
7171
} // namespace lambda_runtime
7272
} // namespace aws

src/runtime.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static size_t write_data(char* ptr, size_t size, size_t nmemb, void* userdata)
7272
// std::isspace has a few edge cases that would trigger UB. In particular, the documentation says:
7373
// "The behavior is undefined if the value of the input is not representable as unsigned char and is not equal to EOF."
7474
// So, this function does the simple obvious thing instead.
75-
static inline bool IsSpace(int ch)
75+
static inline bool is_whitespace(int ch)
7676
{
7777
constexpr int space = 0x20; // space (0x20, ' ')
7878
constexpr int form_feed = 0x0c; // form feed (0x0c, '\f')
@@ -96,9 +96,9 @@ static inline bool IsSpace(int ch)
9696
static inline std::string trim(std::string s)
9797
{
9898
// trim right
99-
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !IsSpace(ch); }).base(), s.end());
99+
s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !is_whitespace(ch); }).base(), s.end());
100100
// trim left
101-
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !IsSpace(ch); }));
101+
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !is_whitespace(ch); }));
102102
return s;
103103
}
104104

tests/main.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <aws/core/utils/logging/ConsoleLogSystem.h>
33
#include "gtest/gtest.h"
44

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

1515
void parse_args(int argc, char** argv)
1616
{
17-
const std::string resourcePrefixOption = "--aws_prefix=";
17+
const std::string resource_prefix_option = "--aws_prefix=";
1818
for (int i = 1; i < argc; i++) {
1919
std::string arg = argv[i];
20-
if (arg.find(resourcePrefixOption) == 0) {
21-
aws_prefix = arg.substr(resourcePrefixOption.length()); // get whatever value after the '='
20+
if (arg.find(resource_prefix_option) == 0) {
21+
aws_prefix = arg.substr(resource_prefix_option.length()); // get whatever value after the '='
2222
break;
2323
}
2424
}
@@ -29,10 +29,10 @@ int main(int argc, char** argv)
2929
parse_args(argc, argv);
3030
Aws::SDKOptions options;
3131
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Warn;
32-
options.loggingOptions.logger_create_fn = GetConsoleLoggerFactory();
32+
options.loggingOptions.logger_create_fn = get_console_logger_factory();
3333
Aws::InitAPI(options);
3434
::testing::InitGoogleTest(&argc, argv);
35-
int exitCode = RUN_ALL_TESTS();
35+
int exit_code = RUN_ALL_TESTS();
3636
Aws::ShutdownAPI(options);
37-
return exitCode;
37+
return exit_code;
3838
}

0 commit comments

Comments
 (0)