Skip to content

Commit f3cb51e

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 ff80e60 commit f3cb51e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
*/
55

66
const bigIntMax = (...args: bigint[]): bigint =>
7-
args.reduce((m, e) => (e > m ? e : m), BigInt(0));
7+
args.reduce((m, e) => {
8+
const _e = BigInt(e);
9+
const _m = BigInt(m);
10+
return _e > _m ? _e : _m;
11+
}, BigInt(0));
812

913
function maxSubsetSum(arr: number[]): number {
1014
const arrCopy: bigint[] = arr.map((x: number): bigint => BigInt(x));

0 commit comments

Comments
 (0)