Skip to content

Commit bc83db6

Browse files
author
Gonzalo Diaz
committed
[BUGFIX] SonarQube: Use new Array() instead of Array().
Built-in constructors should be called consistently with or without "new" typescript:S7723
1 parent 36b484c commit bc83db6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { logger as console } from '../../../logger';
88
function arrayManipulation(n: number, queries: number[][]): number {
99
const LENGTH = n + 1;
1010
const SURROGATE_VALUE = 0;
11-
const result: number[] = Array<number>(LENGTH).fill(SURROGATE_VALUE);
11+
const result: number[] = new Array<number>(LENGTH).fill(SURROGATE_VALUE);
1212
let maximum = 0;
1313

1414
queries.forEach((query) => {

src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function arrayManipulation(n: number, queries: number[][]): number {
88
// last slot for storing accumSum result
99
const LENGTH = n + 2;
1010
const INITIAL_VALUE = 0;
11-
const result = Array(LENGTH).fill(INITIAL_VALUE);
11+
const result = new Array(LENGTH).fill(INITIAL_VALUE);
1212
let maximum = 0;
1313

1414
queries.forEach((query) => {

src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/sherlock_and_anagrams.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import { logger as console } from '../../../logger';
77

88
function extraLongFactorials(n: number): bigint {
9-
const rs = [...Array<number>(n)].reduce((a, b, i) => a * BigInt(i + 1), 1n);
9+
const rs = new Array<bigint>(n)
10+
.fill(1n)
11+
.reduce((a, _b, i) => a * BigInt(i + 1), 1n);
1012
return rs;
1113
}
1214

0 commit comments

Comments
 (0)