Skip to content

Commit

Permalink
fix(backend): Sonar Quality Gate failure due to potential division by…
Browse files Browse the repository at this point in the history
… 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).
  • Loading branch information
dcolina authored Oct 14, 2024
1 parent 8f2ccfa commit 298ce7a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public void process(Job job) {
*/
private void doReadLargeFile(DotTempFile dotTempFile, int nLines, int maxLines ,final Job job) {
final Long totalCount = countLines(dotTempFile);
if (totalCount == null) {
if (totalCount == null || totalCount == 0 ) {
Logger.error(this.getClass(), "No lines in the file or unable to count lines: " + dotTempFile.file.getName());
return;
}
Logger.info(this.getClass(), "Total lines in the file: " + totalCount);
Expand Down

0 comments on commit 298ce7a

Please sign in to comment.