Skip to content

3. Рустаев Самир Рустамович. 614 - #111

Open
samirhappy wants to merge 5 commits into
python-department:mainfrom
samirhappy:part3
Open

samirhappy wants to merge 5 commits into
python-department:mainfrom
samirhappy:part3

Conversation

@samirhappy

Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot added the 614 label Oct 9, 2026
Comment thread src/part3/crud.py
return None
flag = False
index_of_needed_id = 0
for i in range(len(storage)):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Нарушение критерия T5. Минус 0.25 балла

Comment thread src/part3/crud.py
if not name:
print("product name must not be blank")
return None
flag = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Нет необходимости заводить флаг. Вы можете выйти из функции сразу, как найдете данные, нарушающие инварианты. Здесь нет необходимости заводить флаг, и ждать, пока цикл по данным полностью завершится.

Comment thread src/part3/run_admin.py

command = words[0]

if command == "exit" and len(words) == 1:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Здесь правильнее было бы использовать match-case, вместо ветвления. Из-за ветвления очень большая часть логики проверки дублируется (проверка количества слов). Это нарушает критерий S1. Минус балл

Comment thread src/part3/run_admin.py
if command == "create" and len(words) >= 4:
name = " ".join(words[1:-2])
price = Decimal(words[-2])
quantity = int(words[-1])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Нарушение критерия S3. Минус балл

Comment thread src/part3/utils.py
mxlen2 = max(mxlen2, len(name))
mxlen3 = max(mxlen3, len(price))
mxlen4 = max(mxlen4, len(quantity))
s1 = f"| {TABLE_HEADERS[0].ljust(mxlen1)} | {TABLE_HEADERS[1].ljust(mxlen2)} | {TABLE_HEADERS[2].ljust(mxlen3)} | {TABLE_HEADERS[3].ljust(mxlen4)} |"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Нарушение критерия M2. Минус 0.5 балла

Comment thread src/part3/utils.py
"""
# TODO: реализуйте функцию
return ""
mxlen1 = len(TABLE_HEADERS[0])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Эта функция нарушает принцип единой ответственности, т.к. и вычисляет максимальные длины колонок, и форматирует строки. Нарушение критерия S2. Минус балл

Comment thread src/part3/utils.py
# TODO: реализуйте функцию
return ""
mxlen1 = len(TABLE_HEADERS[0])
mxlen2 = len(TABLE_HEADERS[1])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Всю дублирующуюся логику следует выносить в отдельные функции и переиспользовать их

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants