-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: master
Are you sure you want to change the base?
Solutions for task format_linter #1716
Conversation
There was a problem hiding this 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
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" | ||
} |
There was a problem hiding this comment.
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
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() | ||
] |
There was a problem hiding this comment.
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.
There was a problem hiding this 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! ✨
No description provided.