Skip to content

Commit 5e938c6

Browse files
authored
Use forEach() w/ an accumulator over reduce() with an ignored return value (#14817)
Sonar reports this as a bug since it's ignoring a return value in a situation where you don't _have_ to use a reduction/fold.
1 parent 400b193 commit 5e938c6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/client/testing/common/testUtils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ export class TestsHelper implements ITestsHelper {
143143
folders.sort();
144144
const resource = Uri.file(workspaceFolder);
145145
folders.forEach((dir) => {
146-
dir.split(path.sep).reduce((parentPath, currentName, _index, _values) => {
146+
let parentPath = ''; // Accumulator
147+
dir.split(path.sep).forEach((currentName) => {
147148
let newPath = currentName;
148149
let parentFolder: TestFolder | undefined;
149150
if (parentPath.length > 0) {
@@ -175,8 +176,8 @@ export class TestsHelper implements ITestsHelper {
175176
});
176177
tests.testFolders.push(testFolder);
177178
}
178-
return newPath;
179-
}, '');
179+
parentPath = newPath;
180+
});
180181
});
181182
}
182183
public parseTestName(name: string, rootDirectory: string, tests: Tests): TestsToRun | undefined {

0 commit comments

Comments
 (0)