-
Notifications
You must be signed in to change notification settings - Fork 32
[PB-5020]: Fix sonar issues v2 #1671
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying drive-web with
|
| Latest commit: |
7c56fb0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1f65548d.drive-web.pages.dev |
| Branch Preview URL: | https://fix-sonar-issues-v2.drive-web.pages.dev |
f4d9c8d to
da3eff8
Compare
src/app/network/DownloadManager.ts
Outdated
| private static readonly handleConnectionLostError = (err: unknown, taskId: string) => { | ||
| tasksService.updateTask({ | ||
| taskId, | ||
| merge: { status: TaskStatus.Error, subtitle: t('error.connectionLostError') as string }, |
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.
I think that the cast to string is not necessary, could remove it :)
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.
Done!
src/app/network/DownloadManager.ts
Outdated
| throw err; | ||
| }; | ||
|
|
||
| private static readonly handleServerOrCancelledError = ( |
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.
this function name coud lead to confusion, the function returns boolean value, dependeing of certain conditions, maybe shouldContinueAfterError or something similar fits better with the purpose of the function
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.
Done!
src/app/network/DownloadManager.ts
Outdated
| this.handleConnectionLostError(err, taskId); | ||
| } | ||
|
|
||
| const updateTaskWithErrorStatus = this.handleServerOrCancelledError( |
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.
same as the function name, this not fits boolean naming convention, seems more like a function name because it has an action on the name, something as shouldContinueProcessing fits better I think
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.
Done!
- Rename handleServerOrCancelledError to shouldUpdateTaskWithError for clearer intent - Replace variable updateTaskWithErrorStatus with shouldContinueProcessing - Remove unnecessary type casting in handleConnectionLostError
CandelR
left a comment
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.
Remember to check the sonar cloud new issues
src/app/network/DownloadManager.ts
Outdated
| this.handleConnectionLostError(err, taskId); | ||
| } | ||
|
|
||
| const shouldContinueProcessing = this.shouldUpdateTaskWithError(downloadTask, isServerError, filePickerCancelled); |
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.
To me, the name of the function and what it does still doesn't make sense; it's not clear.
It's called shouldUpdateTaskWithError, and it returns true if it doesn't update it and false if it does.
I recommend adding jsdoc to the functions of this class, because I find it a bit confusing. It's not the best solution, but I don't think we need to refactor this in this task either
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.
Done! Do I need to wait for @internxt/cryptography ’s approval before sending this task to QA?
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.
Not necessary in this one, pass it to QA
Extracted task status updates and retry item removal logic into separate methods to improve code clarity and maintainability. The shouldContinueAfterError function now focuses solely on decision logic.
|



Description
Removed redundant cycles, reduced cognitive complexity, deleted an unused component and simplified nested code.
Related Issues
Related Pull Requests
Checklist
Testing Process
Additional Notes