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

Sonar Quality Gate failure due to potential division by zero #30337

Closed
4 tasks
dcolina opened this issue Oct 14, 2024 · 0 comments · Fixed by #30338
Closed
4 tasks

Sonar Quality Gate failure due to potential division by zero #30337

dcolina opened this issue Oct 14, 2024 · 0 comments · Fixed by #30338

Comments

@dcolina
Copy link
Contributor

dcolina commented Oct 14, 2024

Parent Issue

No parent issue identified.

Problem Statement

The Sonar Quality Gate is failing due to uncovered code that could potentially lead to a division by zero. The specific issue reported by Sonar is:

Make sure "totalCount" can't be zero before doing this division.

This issue poses a risk of runtime errors and must be addressed to pass the Quality Gate and ensure code stability.

Steps to Reproduce

  1. Run the Sonar analysis on the current codebase.
  2. Observe the Quality Gate failure due to the uncovered division by zero issue.
  3. Check the relevant section of code where the division using totalCount occurs.

Acceptance Criteria

  1. The code should be updated to ensure that totalCount is properly validated and cannot be zero before performing the division.
  2. The Sonar Quality Gate should pass after this issue is resolved.
  3. Tests should be added or updated to ensure this condition is covered and the division by zero is prevented.

dotCMS Version

Not applicable.

Proposed Objective

Quality Assurance

Proposed Priority

Priority 1 - Show Stopper

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No external links provided.

Assumptions & Initiation Needs

  1. Review the section of code where the division using totalCount occurs and ensure it is properly protected against a division by zero.
  2. Update the necessary tests to cover this scenario.

Quality Assurance Notes & Workarounds

No workaround is available. The code must be updated to handle this potential division by zero.

Sub-Tasks & Estimates

  • Review the codebase and locate the division by zero issue.
  • Add checks to ensure totalCount is not zero before performing the division.
  • Update unit tests to ensure this condition is covered.
  • Run Sonar analysis again to ensure the Quality Gate passes.
@dcolina dcolina converted this from a draft issue Oct 14, 2024
@dcolina dcolina self-assigned this Oct 14, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 14, 2024
… zero (#30337) (#30338)

### Proposed Changes
* To avoid division by zero in the LargeFileReader class, you should add
a check before performing any division operation. In this class, the
division operation is performed when calculating the progressPercentage.

### Additional Info
Related to #30337 (Sonar Quality Gate failure due to potential division
by zero).
@github-project-automation github-project-automation bot moved this from In Review to Internal QA in dotCMS - Product Planning Oct 14, 2024
@nollymar nollymar moved this from Internal QA to Done in dotCMS - Product Planning Oct 14, 2024
spbolton pushed a commit that referenced this issue Nov 11, 2024
… zero (#30337) (#30338)

### Proposed Changes
* To avoid division by zero in the LargeFileReader class, you should add
a check before performing any division operation. In this class, the
division operation is performed when calculating the progressPercentage.

### Additional Info
Related to #30337 (Sonar Quality Gate failure due to potential division
by zero).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants