Skip to content

Commit d56e7c9

Browse files
author
Gonzalo Diaz
committed
[BUGFIX] sonarqube: Prefer Math.max() to simplify ternary expressions.
Ternary expressions should be replaced with "Math.min()" or "Math.max()" for simple comparisons typescript:S7766
1 parent c092b27 commit d56e7c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
*/
55

66
const bigIntMax = (...args: bigint[]): bigint =>
7-
args.reduce((m, e) => {
8-
const _e = BigInt(e);
9-
const _m = BigInt(m);
10-
return _e > _m ? _e : _m;
11-
}, BigInt(0));
7+
// if (args.length === 0) {
8+
// throw new Error('bigIntMax requires at least one argument.');
9+
// }
10+
args.reduce((max, current) => {
11+
if (current > max) {
12+
return current;
13+
}
14+
return max;
15+
});
1216

1317
function maxSubsetSum(arr: number[]): number {
1418
const arrCopy: bigint[] = arr.map(BigInt);

0 commit comments

Comments
 (0)