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

Solutions for task format_linter #1716

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SviatoslavTataryn
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great work so far! 👏 However, there's a small issue with code repetition in your format_linter_report and format_single_linter_file functions. To make your code more efficient and easier to maintain, try to implement the DRY (Don't Repeat Yourself) principle by using the format_linter_error function you've already defined. Keep going, you're doing well! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

app/main.py Outdated
Comment on lines 11 to 24
def format_single_linter_file(file_path: str, errors: list) -> dict:
# write your code here
pass
return {
"errors": [
{
"line": item["line_number"],
"column": item["column_number"],
"message": item["text"],
"name": item["code"],
"source": "flake8"
} for item in errors
],
"path": file_path,
"status": "failed"
}

Choose a reason for hiding this comment

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

There is a duplication in your code. You are repeating the same block of code in the format_single_linter_file function and inside the format_linter_report function. To follow the DRY (Don't Repeat Yourself) principle, you should reuse the format_linter_error function inside the format_single_linter_file function. This way, you avoid repeating the same logic for formatting linter errors.

app/main.py Outdated
Comment on lines 27 to 42
def format_linter_report(linter_report: dict) -> list:
# write your code here
pass
return [
{
"errors": [
{
"line": error["line_number"],
"column": error["column_number"],
"message": error["text"],
"name": error["code"],
"source": "flake8"
} for error in errors
],
"path": path,
"status": "failed" if errors else "passed"
} for path, errors in linter_report.items()
]

Choose a reason for hiding this comment

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

In the format_linter_report function, you are repeating the same block of code for formatting linter errors. To avoid this repetition, you can use the format_linter_error function that you have defined at the top of your file. This way, you can keep your code DRY (Don't Repeat Yourself) and make it more maintainable and easier to read.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job! Your code is clear and concise, adhering to best practices. Keep up the good work! 🎉

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

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