Skip to content

Conversation

@terrerox
Copy link
Contributor

@terrerox terrerox commented Sep 17, 2025

Description

Removed redundant cycles, reduced cognitive complexity, deleted an unused component and simplified nested code.

Related Issues

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Additional Notes

@terrerox terrerox self-assigned this Sep 17, 2025
@terrerox terrerox requested a review from CandelR as a code owner September 17, 2025 01:54
@vercel
Copy link

vercel bot commented Sep 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
drive-web Ready Ready Preview Comment Oct 9, 2025 7:32pm

@terrerox terrerox marked this pull request as draft September 17, 2025 01:54
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 17, 2025

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

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

View logs

@terrerox terrerox marked this pull request as ready for review September 18, 2025 17:11
@terrerox terrerox requested a review from a team as a code owner September 18, 2025 17:11
@terrerox terrerox changed the title [PB-4522]: Fix sonar issues v2 [PB-5020]: Fix sonar issues v2 Sep 23, 2025
private static readonly handleConnectionLostError = (err: unknown, taskId: string) => {
tasksService.updateTask({
taskId,
merge: { status: TaskStatus.Error, subtitle: t('error.connectionLostError') as string },
Copy link
Collaborator

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

throw err;
};

private static readonly handleServerOrCancelledError = (
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

this.handleConnectionLostError(err, taskId);
}

const updateTaskWithErrorStatus = this.handleServerOrCancelledError(
Copy link
Collaborator

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

Copy link
Contributor Author

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
Copy link
Collaborator

@CandelR CandelR left a 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

this.handleConnectionLostError(err, taskId);
}

const shouldContinueProcessing = this.shouldUpdateTaskWithError(downloadTask, isServerError, filePickerCancelled);
Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Collaborator

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.
@terrerox terrerox requested a review from sg-gs October 7, 2025 21:09
@terrerox terrerox requested review from sg-gs and removed request for sg-gs October 9, 2025 14:35
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 9, 2025

@terrerox terrerox merged commit d375f7d into master Oct 9, 2025
15 of 16 checks passed
@terrerox terrerox deleted the fix/sonar-issues-v2 branch October 9, 2025 19:40
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.

4 participants