Skip to content

Hw2 - #6

Open
EStarikov wants to merge 22 commits into
mainfrom
hw2
Open

Hw2#6
EStarikov wants to merge 22 commits into
mainfrom
hw2

Conversation

@EStarikov

@EStarikov EStarikov commented Mar 27, 2026 •

Copy link
Copy Markdown
Owner

Пустые CMakeLists.txt нужны чтобы проходил clang-tidy, при мердже они будут удалены

@yurii-litvinov yurii-litvinov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Комментарии к коммитам не очень. См. https://mukhutdinov.com/conventional-commits.html

Comment thread src/hw2/registration.h Outdated
#include <stdbool.h>
#include <stddef.h>

typedef struct Node Node;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Внешнему миру вовсе незачем знать, что в словаре есть какие-то узлы, это объявление стоит спрятать в .c и подправить функции интерфейса модуля, чтобы они его не показывали.

Comment thread src/hw2/registration.h Outdated

typedef struct Node Node;
typedef struct AVL {
Node* root;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И уж тем более внешнему миру не нужно знать про устройство дерева. И я бы сказал, что внешнему миру не нужно знать, что это вообще дерево, и переименовал бы эту структуру в Dictionary или что-то такое.

Comment thread src/hw2/registration.h Outdated
Node* insertAVL(char* code, char* name, Node* node, bool* err);
const char* contains(Node* node, char* code);
void freeAVL(AVL* tree);
int saveAVLtoFILE(char* filename, AVL* tree);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FILE капсом выглядит странно

Comment thread src/hw2/registration.h
Node* root;
} AVL;

void split(char* s, char* code, char* name, size_t len, char separator);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split вроде как к дереву не относится

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Comment thread src/hw2/registration.h Outdated
} AVL;

void split(char* s, char* code, char* name, size_t len, char separator);
AVL* readFileToAVL(char* filename);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

К каждой функции из заголовочного файла нужен комментарий

Comment thread src/hw2/registration.c Outdated
Comment on lines +194 to +195
}
Node* deleteAVL(Node* node, char* code, bool* err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
Node* deleteAVL(Node* node, char* code, bool* err)
}
Node* deleteAVL(Node* node, char* code, bool* err)

Comment thread src/hw2/registration.c
Comment on lines +268 to +270
free(node->code);
free(node->name);
free(node);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделали бы функцию, которая это делает

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже не поправлено

Comment thread src/hw2/tests.c Outdated
#include <stdlib.h>
#include <string.h>

void test_empty_tree()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выше был camelCase, тут snake_case, нехорошо

Comment thread src/hw2/tests.c
Comment on lines +31 to +32
AVL* tree = malloc(sizeof(AVL));
tree->root = NULL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тестироваться должно внешнее поведение, тест не должен лезть во внутреннее представление абстрактного типа данных. И тогда и определение AVL в хедере будет не нужно.

Comment thread src/hw2/utility.c Outdated
int main()
{
char userCom[100];
char com[100];

@yurii-litvinov yurii-litvinov May 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не сокращайте имена вообще

Comment thread src/hw2/registration.c

static Node* rotateLeft(Node* a)
{
Node* b = a->right;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как-то не поправлено, и ниже с большими вращениями вообще жесть в этом плане

Comment thread src/hw2/registration.c
Comment on lines +268 to +270
free(node->code);
free(node->name);
free(node);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже не поправлено

Comment thread src/hw2/registration.h
Node* root;
} AVL;

void split(char* s, char* code, char* name, size_t len, char separator);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Comment thread src/hw2/tests.c
{
printf("Тест 1: Пустое дерево... ");

AVL* tree = readFileToAVL("nonexistent.txt");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не уверен, что это скомпилируется. В CI тесты даже не пытаются собираться, кстати

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants