Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Enforce stricter identifier naming using clang-tidy. #2404

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,9 @@ jobs:
- run:
apt-get install -y --no-install-recommends
ca-certificates
clang-tidy-12
clang-tidy-14
- checkout
- run: git submodule update --init --recursive
- run: cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- run:
other/analysis/run-clang-tidy ||
other/analysis/run-clang-tidy ||
Expand Down
35 changes: 35 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# vim:ft=yaml
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: Camel_Snake_Case
- key: readability-identifier-naming.ConstantCase
value: lower_case
# bootstrap-daemon has these.
- key: readability-identifier-naming.ConstantIgnoredRegexp
value: "^NAME_.*"
- key: readability-identifier-naming.EnumCase
value: Camel_Snake_Case
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.GlobalConstantCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.MacroDefinitionIgnoredRegexp
value: "^_.*|nullable|non_null|nullptr|static_assert|ck_.*"
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.StructCase
value: Camel_Snake_Case
- key: readability-identifier-naming.TypedefCase
value: Camel_Snake_Case
- key: readability-identifier-naming.TypedefIgnoredRegexp
value: ".*_cb"
- key: readability-identifier-naming.UnionCase
value: Camel_Snake_Case
- key: readability-identifier-naming.VariableCase
value: lower_case
190 changes: 95 additions & 95 deletions auto_tests/TCP_test.c

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions auto_tests/auto_test_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define ABORT_ON_LOG_ERROR true
#endif

Run_Auto_Options default_run_auto_options()
Run_Auto_Options default_run_auto_options(void)
{
return (Run_Auto_Options) {
.graph = GRAPH_COMPLETE,
Expand All @@ -27,7 +27,7 @@ static const struct BootstrapNodes {
const char *ip;
uint16_t port;
const uint8_t key[32];
} BootstrapNodes[] = {
} bootstrap_nodes[] = {
#ifndef USE_TEST_NETWORK
{
"tox.abilinski.com", 33445,
Expand Down Expand Up @@ -80,10 +80,10 @@ void bootstrap_tox_live_network(Tox *tox, bool enable_tcp)
{
ck_assert(tox != nullptr);

for (size_t j = 0; BootstrapNodes[j].ip != nullptr; ++j) {
const char *ip = BootstrapNodes[j].ip;
uint16_t port = BootstrapNodes[j].port;
const uint8_t *key = BootstrapNodes[j].key;
for (size_t j = 0; bootstrap_nodes[j].ip != nullptr; ++j) {
const char *ip = bootstrap_nodes[j].ip;
uint16_t port = bootstrap_nodes[j].port;
const uint8_t *key = bootstrap_nodes[j].key;

Tox_Err_Bootstrap err;
tox_bootstrap(tox, ip, port, key, &err);
Expand Down
8 changes: 4 additions & 4 deletions auto_tests/conference_av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static bool test_audio(AutoTox *autotoxes, const bool *disabled, bool quiet)
printf("testing sending and receiving audio\n");
}

const int16_t PCM[GROUP_AV_TEST_SAMPLES] = {0};
const int16_t pcm[GROUP_AV_TEST_SAMPLES] = {0};

reset_received_audio(autotoxes);

Expand All @@ -227,7 +227,7 @@ static bool test_audio(AutoTox *autotoxes, const bool *disabled, bool quiet)
continue;
}

if (toxav_group_send_audio(autotoxes[i].tox, 0, PCM, GROUP_AV_TEST_SAMPLES, 1, 48000) != 0) {
if (toxav_group_send_audio(autotoxes[i].tox, 0, pcm, GROUP_AV_TEST_SAMPLES, 1, 48000) != 0) {
if (!quiet) {
ck_abort_msg("#%u failed to send audio", autotoxes[i].index);
}
Expand Down Expand Up @@ -268,12 +268,12 @@ static void test_eventual_audio(AutoTox *autotoxes, const bool *disabled, uint64

static void do_audio(AutoTox *autotoxes, uint32_t iterations)
{
const int16_t PCM[GROUP_AV_TEST_SAMPLES] = {0};
const int16_t pcm[GROUP_AV_TEST_SAMPLES] = {0};
printf("running audio for %u iterations\n", iterations);

for (uint32_t f = 0; f < iterations; ++f) {
for (uint32_t i = 0; i < NUM_AV_GROUP_TOX; ++i) {
ck_assert_msg(toxav_group_send_audio(autotoxes[i].tox, 0, PCM, GROUP_AV_TEST_SAMPLES, 1, 48000) == 0,
ck_assert_msg(toxav_group_send_audio(autotoxes[i].tox, 0, pcm, GROUP_AV_TEST_SAMPLES, 1, 48000) == 0,
"#%u failed to send audio", autotoxes[i].index);
iterate_all_wait(autotoxes, NUM_AV_GROUP_TOX, ITERATION_INTERVAL);
}
Expand Down
10 changes: 5 additions & 5 deletions auto_tests/file_transfer_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ static void file_transfer_test(void)
uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, nullptr);
ck_assert_msg(test == 0, "Failed to add friend error code: %u", test);

uint8_t dhtKey[TOX_PUBLIC_KEY_SIZE];
tox_self_get_dht_id(tox1, dhtKey);
uint16_t dhtPort = tox_self_get_udp_port(tox1, nullptr);
uint8_t dht_key[TOX_PUBLIC_KEY_SIZE];
tox_self_get_dht_id(tox1, dht_key);
uint16_t dht_port = tox_self_get_udp_port(tox1, nullptr);

tox_bootstrap(tox2, TOX_LOCALHOST, dhtPort, dhtKey, nullptr);
tox_bootstrap(tox3, TOX_LOCALHOST, dhtPort, dhtKey, nullptr);
tox_bootstrap(tox2, TOX_LOCALHOST, dht_port, dht_key, nullptr);
tox_bootstrap(tox3, TOX_LOCALHOST, dht_port, dht_key, nullptr);

printf("Waiting for toxes to come online\n");

Expand Down
4 changes: 2 additions & 2 deletions auto_tests/tox_strncasecmp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ typedef enum {
POSITIVE
} Comparison;

static const char *Comparison_Str[] = { "NEGATIVE", "ZERO", "POSITIVE" };
static const char *comparison_str[] = { "NEGATIVE", "ZERO", "POSITIVE" };

static void verify(const char *s1, const char *s2, size_t n, Comparison expected)
{
Expand All @@ -19,7 +19,7 @@ static void verify(const char *s1, const char *s2, size_t n, Comparison expected

ck_assert_msg(actual == expected,
"tox_strncasecmp(\"%s\", \"%s\", %u) == %s, but expected %s.",
s1, s2, (unsigned)n, Comparison_Str[actual], Comparison_Str[expected]);
s1, s2, (unsigned)n, comparison_str[actual], comparison_str[expected]);
}

static void test_general(void)
Expand Down
Loading
Loading