lint: stricter casing rules

This commit is contained in:
2025-08-27 19:47:19 +02:00
parent b56aa19671
commit 6d9107b360
14 changed files with 35 additions and 31 deletions

View File

@@ -30,6 +30,10 @@ CheckOptions:
- key: readability-identifier-naming.ConstantCase
value: "UPPER_CASE"
- key: readability-identifier-naming.EnumCase
value: "CamelCase"
- key: readability-identifier-naming.FunctionCase
value: "lower_case"
- key: readability-identifier-length.VariableThreshold
value: "2"

View File

@@ -8,7 +8,7 @@
#include "macros.h"
#include "util.h"
enum introspection_type {
enum IntrospectionType {
STRING,
BOOL,
NUMBER,
@@ -26,7 +26,7 @@ static const char* NNULLABLE const INTROS_TYS_NAMES[] = {
struct introspection_item {
char* NNULLABLE name;
size_t offset;
enum introspection_type typ;
enum IntrospectionType typ;
};
#define INTROS_ITEM(key, table, ty) \
@@ -90,9 +90,9 @@ BUILD(colors, COLORS, TABLE_COLORS);
BUILD(chars, CHARS, TABLE_CHARS);
#define TABLE_FUNCTIONS(F, name) \
F(enum keys, poweroff, KEY, F1, name) \
F(enum keys, reboot, KEY, F2, name) \
F(enum keys, refresh, KEY, F5, name)
F(enum Keys, poweroff, KEY, F1, name) \
F(enum Keys, reboot, KEY, F2, name) \
F(enum Keys, refresh, KEY, F5, name)
BUILD(functions, FUNCTIONS, TABLE_FUNCTIONS);

View File

@@ -3,7 +3,7 @@
#include <stdlib.h>
enum keys {
enum Keys {
ESC,
F1,
F2,
@@ -66,7 +66,7 @@ static const char* const KEY_NAMES[] = {
};
struct key_mapping {
enum keys key;
enum Keys key;
const char* sequences[3];
};

View File

@@ -26,7 +26,7 @@ struct pamh_getenv_status {
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
char* NNULLABLE user,
struct passwd* NNULLABLE pw,
enum session_type session_typ);
enum SessionType session_typ);
void free_envlist(char** NNULLABLE envlist);
pam_handle_t* NULLABLE get_pamh(char* NNULLABLE user, char* NNULLABLE passwd);

View File

@@ -6,7 +6,7 @@
#include "macros.h"
#include "util.h"
enum session_type {
enum SessionType {
XORG,
WAYLAND,
SHELL,
@@ -16,7 +16,7 @@ struct session {
char* NNULLABLE name;
char* NNULLABLE exec;
char* NULLABLE tryexec;
enum session_type type;
enum SessionType type;
};
struct Vector get_avaliable_sessions();

View File

@@ -39,7 +39,7 @@
#define VALUES_SEPR 3
#define VALUE_MAXLEN (BOX_WIDTH - VALUES_COL + 1 - BOX_HMARGIN - 2)
enum input { SESSION, USER, PASSWD };
enum Input { SESSION, USER, PASSWD };
extern const u_char INPUTS_N;
void setup(struct config* config);
@@ -47,7 +47,7 @@ int load(struct Vector* users, struct Vector* sessions);
void print_err(const char* /*msg*/);
void print_errno(const char* /*descr*/);
void ui_update_field(enum input focused_input);
void ui_update_field(enum Input focused_input);
void ui_update_ffield();
void ui_update_ofield(struct opts_field* self);
void ui_update_cursor_focus();

View File

@@ -6,7 +6,7 @@
#include "macros.h"
#include "ui.h"
extern enum input focused_input;
extern enum Input focused_input;
extern struct opts_field of_session;
extern struct opts_field of_user;
@@ -15,7 +15,7 @@ extern struct opts_field of_passwd;
extern struct Vector* UNULLABLE gusers;
extern struct Vector* UNULLABLE gsessions;
struct opts_field* NNULLABLE get_opts_field(enum input from);
struct opts_field* NNULLABLE get_opts_field(enum Input from);
struct opts_field* NNULLABLE get_opts_ffield();
struct user st_user();

View File

@@ -10,8 +10,8 @@
#include "keys.h"
int find_keyname(enum keys* at, const char* name);
enum keys find_ansi(const char* seq);
int find_keyname(enum Keys* at, const char* name);
enum Keys find_ansi(const char* seq);
void read_press(u_char* length, char* out);
// non blocking, waits up to tv or interrupt, returns true if actually read
bool read_press_nb(u_char* length, char* out, struct timeval* tv);

View File

@@ -117,11 +117,11 @@ union typ_ptr {
char** string;
long long* number;
bool* boolean;
enum keys* key;
enum Keys* key;
struct Vector* vec;
uintptr_t ptr;
};
struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
struct parser_error parse_key(enum IntrospectionType typ, union typ_ptr at,
char* key, size_t offset) {
char* aux_str = NULL;
struct parser_error aux_err;

View File

@@ -68,7 +68,7 @@ free_new_envlist_extra:
return NULL;
}
char* NULLABLE xdg_ssession_type_str(enum session_type typ) {
char* NULLABLE xdg_ssession_type_str(enum SessionType typ) {
char* xdg_session_type = NULL;
if (typ == SHELL) xdg_session_type = "tty";
if (typ == XORG) xdg_session_type = "x11";
@@ -91,7 +91,7 @@ char* NULLABLE xdg_ssession_type_str(enum session_type typ) {
struct pamh_getenv_status pamh_get_complete_env(pam_handle_t* handle,
char* NNULLABLE user,
struct passwd* NNULLABLE pw,
enum session_type session_typ) {
enum SessionType session_typ) {
struct pamh_getenv_status status;
char** envlist = pam_getenvlist(handle);
if (!envlist) FAIL(status, PAMH_ERR_ERRNO, "pam_getenvlist");

View File

@@ -13,7 +13,7 @@
#include "util.h"
struct source_dir {
enum session_type type;
enum SessionType type;
char* dir;
};
@@ -72,7 +72,7 @@ struct status cb(void* _ctx, char* NULLABLE table, char* key, char* value) {
// also, always return 0 or we will break parsing and we don't want a bad
// desktop file to break all possible sessions
static enum session_type session_type;
static enum SessionType session_type;
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
static int fn(const char* fpath, const struct stat* sb, int typeflag) {
// guessing symlink behavior

View File

@@ -151,7 +151,7 @@ void ui_update_cursor_focus() {
(void)printf("\x1b[%d;%dH", line, col);
}
void ui_update_field(enum input focused_input) {
void ui_update_field(enum Input focused_input) {
if (focused_input == PASSWD) {
print_passwd(utf8len(of_passwd.efield.content), false);
} else if (focused_input == SESSION) {
@@ -170,7 +170,7 @@ void ui_update_ffield() {
}
void ui_update_ofield(struct opts_field* NNULLABLE self) {
enum input input;
enum Input input;
if (self == &of_session)
input = SESSION;
else if (self == &of_user)
@@ -280,7 +280,7 @@ int load(struct Vector* users, struct Vector* sessions) {
(void)fflush(stdout);
if (!read_press_nb(&len, seq, &tv)) continue;
if (*seq == '\x1b') {
enum keys ansi_code = find_ansi(seq);
enum Keys ansi_code = find_ansi(seq);
if (ansi_code != -1) {
if (ansi_code == ESC) {
esc = 2;

View File

@@ -4,7 +4,7 @@
#include "ui.h"
#include "users.h"
enum input focused_input = PASSWD;
enum Input focused_input = PASSWD;
struct Vector* gusers;
struct Vector* gsessions;
@@ -13,7 +13,7 @@ struct opts_field of_session;
struct opts_field of_user;
struct opts_field of_passwd;
struct opts_field* NNULLABLE get_opts_field(enum input from) {
struct opts_field* NNULLABLE get_opts_field(enum Input from) {
if (from == SESSION) return &of_session;
if (from == USER) return &of_user;
if (from == PASSWD) return &of_passwd;

View File

@@ -13,10 +13,10 @@
static int selret_magic();
int find_keyname(enum keys* at, const char* name) {
int find_keyname(enum Keys* at, const char* name) {
for (size_t i = 0; i < LEN(KEY_MAPPINGS); i++) {
if (strcmp(KEY_NAMES[i], name) == 0) {
*at = (enum keys)i;
*at = (enum Keys)i;
return 0;
}
}
@@ -24,12 +24,12 @@ int find_keyname(enum keys* at, const char* name) {
return -1;
}
enum keys find_ansi(const char* seq) {
enum Keys find_ansi(const char* seq) {
for (size_t i = 0; i < LEN(KEY_MAPPINGS); i++) {
struct key_mapping mapping = KEY_MAPPINGS[i];
for (size_t j = 0; mapping.sequences[j] != NULL; j++) {
if (strcmp(mapping.sequences[j], seq) == 0) {
return (enum keys)i;
return (enum Keys)i;
}
}
}