Skip to content

Commit b9a6418

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 javascript:S7766
1 parent 8cfa546 commit b9a6418

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/projecteuler/problem0005.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function _replaceMaximum(_element, count, _group) {
2525
const group = _group;
2626
if (Object.hasOwn(group, _element)) {
2727
const elem = _group[_element];
28-
group[_element] = count > elem ? count : elem;
28+
group[_element] = Math.max(count, elem);
2929
} else {
3030
group[_element] = count;
3131
}

src/projecteuler/problem0018.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function problem0018(_triangle) {
2727
console.debug('leafs count', leafs.length, 'leafs', leafs);
2828

2929
const __START_FROM__ = 0;
30-
const max = leafs.reduce((a, b) => (a > b ? a : b), __START_FROM__);
30+
const max = leafs.reduce((a, b) => Math.max(a, b), __START_FROM__);
3131

3232
return max;
3333
}

0 commit comments

Comments
 (0)