Merge pull request #704 from dorny/bugfix/703-refactor-deprecated-substr-function

This commit is contained in:
Jozef Izso
2025-12-29 15:08:16 +01:00
committed by GitHub
10 changed files with 24 additions and 24 deletions

24
dist/index.js generated vendored
View File

@@ -729,12 +729,12 @@ class DartJsonParser {
getRelativePath(path) { getRelativePath(path) {
const prefix = 'file://'; const prefix = 'file://';
if (path.startsWith(prefix)) { if (path.startsWith(prefix)) {
path = path.substr(prefix.length); path = path.substring(prefix.length);
} }
path = (0, path_utils_1.normalizeFilePath)(path); path = (0, path_utils_1.normalizeFilePath)(path);
const workDir = this.getWorkDir(path); const workDir = this.getWorkDir(path);
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length); path = path.substring(workDir.length);
} }
return path; return path;
} }
@@ -893,7 +893,7 @@ class DotnetNunitParser {
path = (0, path_utils_1.normalizeFilePath)(path); path = (0, path_utils_1.normalizeFilePath)(path);
const workDir = this.getWorkDir(path); const workDir = this.getWorkDir(path);
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length); path = path.substring(workDir.length);
} }
return path; return path;
} }
@@ -997,7 +997,7 @@ class DotnetTrxParser {
const duration = durationAttr ? (0, parse_utils_1.parseNetDuration)(durationAttr) : 0; const duration = durationAttr ? (0, parse_utils_1.parseNetDuration)(durationAttr) : 0;
const resultTestName = r.result.$.testName; const resultTestName = r.result.$.testName;
const testName = resultTestName.startsWith(className) && resultTestName[className.length] === '.' const testName = resultTestName.startsWith(className) && resultTestName[className.length] === '.'
? resultTestName.substr(className.length + 1) ? resultTestName.substring(className.length + 1)
: resultTestName; : resultTestName;
const test = new Test(testName, r.result.$.outcome, duration, error); const test = new Test(testName, r.result.$.outcome, duration, error);
tc.tests.push(test); tc.tests.push(test);
@@ -1064,7 +1064,7 @@ class DotnetTrxParser {
const filePath = (0, path_utils_1.normalizeFilePath)(fileStr); const filePath = (0, path_utils_1.normalizeFilePath)(fileStr);
const workDir = this.getWorkDir(filePath); const workDir = this.getWorkDir(filePath);
if (workDir) { if (workDir) {
const file = filePath.substr(workDir.length); const file = filePath.substring(workDir.length);
if (trackedFiles.includes(file)) { if (trackedFiles.includes(file)) {
const line = parseInt(lineStr); const line = parseInt(lineStr);
return { path: file, line }; return { path: file, line };
@@ -1550,7 +1550,7 @@ class JestJunitParser {
path = (0, path_utils_1.normalizeFilePath)(path); path = (0, path_utils_1.normalizeFilePath)(path);
const workDir = this.getWorkDir(path); const workDir = this.getWorkDir(path);
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length); path = path.substring(workDir.length);
} }
return path; return path;
} }
@@ -1621,7 +1621,7 @@ class MochaJsonParser {
} }
processTest(suite, test, result) { processTest(suite, test, result) {
const groupName = test.fullTitle !== test.title const groupName = test.fullTitle !== test.title
? test.fullTitle.substr(0, test.fullTitle.length - test.title.length).trimEnd() ? test.fullTitle.substring(0, test.fullTitle.length - test.title.length).trimEnd()
: null; : null;
let group = suite.groups.find(grp => grp.name === groupName); let group = suite.groups.find(grp => grp.name === groupName);
if (group === undefined) { if (group === undefined) {
@@ -1656,7 +1656,7 @@ class MochaJsonParser {
path = (0, path_utils_1.normalizeFilePath)(path); path = (0, path_utils_1.normalizeFilePath)(path);
const workDir = this.getWorkDir(path); const workDir = this.getWorkDir(path);
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length); path = path.substring(workDir.length);
} }
return path; return path;
} }
@@ -1856,7 +1856,7 @@ class PhpunitJunitParser {
path = (0, path_utils_1.normalizeFilePath)(path); path = (0, path_utils_1.normalizeFilePath)(path);
const workDir = this.getWorkDir(path); const workDir = this.getWorkDir(path);
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length); path = path.substring(workDir.length);
} }
return path; return path;
} }
@@ -1977,7 +1977,7 @@ class RspecJsonParser {
} }
processTest(suite, test, result) { processTest(suite, test, result) {
const groupName = test.full_description !== test.description const groupName = test.full_description !== test.description
? test.full_description.substr(0, test.full_description.length - test.description.length).trimEnd() ? test.full_description.substring(0, test.full_description.length - test.description.length).trimEnd()
: null; : null;
let group = suite.groups.find(grp => grp.name === groupName); let group = suite.groups.find(grp => grp.name === groupName);
if (group === undefined) { if (group === undefined) {
@@ -2823,7 +2823,7 @@ function ellipsis(text, maxLength) {
if (text.length <= maxLength) { if (text.length <= maxLength) {
return text; return text;
} }
return text.substr(0, maxLength - 3) + '...'; return text.substring(0, maxLength - 3) + '...';
} }
function formatTime(ms) { function formatTime(ms) {
if (ms > 1000) { if (ms > 1000) {
@@ -2942,7 +2942,7 @@ function getBasePath(path, trackedFiles) {
if (max === '') { if (max === '') {
return undefined; return undefined;
} }
const base = path.substr(0, path.length - max.length); const base = path.substring(0, path.length - max.length);
return base; return base;
} }

View File

@@ -242,13 +242,13 @@ export class DartJsonParser implements TestParser {
private getRelativePath(path: string): string { private getRelativePath(path: string): string {
const prefix = 'file://' const prefix = 'file://'
if (path.startsWith(prefix)) { if (path.startsWith(prefix)) {
path = path.substr(prefix.length) path = path.substring(prefix.length)
} }
path = normalizeFilePath(path) path = normalizeFilePath(path)
const workDir = this.getWorkDir(path) const workDir = this.getWorkDir(path)
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length) path = path.substring(workDir.length)
} }
return path return path
} }

View File

@@ -136,7 +136,7 @@ export class DotnetNunitParser implements TestParser {
path = normalizeFilePath(path) path = normalizeFilePath(path)
const workDir = this.getWorkDir(path) const workDir = this.getWorkDir(path)
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length) path = path.substring(workDir.length)
} }
return path return path
} }

View File

@@ -94,7 +94,7 @@ export class DotnetTrxParser implements TestParser {
const resultTestName = r.result.$.testName const resultTestName = r.result.$.testName
const testName = const testName =
resultTestName.startsWith(className) && resultTestName[className.length] === '.' resultTestName.startsWith(className) && resultTestName[className.length] === '.'
? resultTestName.substr(className.length + 1) ? resultTestName.substring(className.length + 1)
: resultTestName : resultTestName
const test = new Test(testName, r.result.$.outcome, duration, error) const test = new Test(testName, r.result.$.outcome, duration, error)
@@ -177,7 +177,7 @@ export class DotnetTrxParser implements TestParser {
const filePath = normalizeFilePath(fileStr) const filePath = normalizeFilePath(fileStr)
const workDir = this.getWorkDir(filePath) const workDir = this.getWorkDir(filePath)
if (workDir) { if (workDir) {
const file = filePath.substr(workDir.length) const file = filePath.substring(workDir.length)
if (trackedFiles.includes(file)) { if (trackedFiles.includes(file)) {
const line = parseInt(lineStr) const line = parseInt(lineStr)
return {path: file, line} return {path: file, line}

View File

@@ -106,7 +106,7 @@ export class JestJunitParser implements TestParser {
path = normalizeFilePath(path) path = normalizeFilePath(path)
const workDir = this.getWorkDir(path) const workDir = this.getWorkDir(path)
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length) path = path.substring(workDir.length)
} }
return path return path
} }

View File

@@ -61,7 +61,7 @@ export class MochaJsonParser implements TestParser {
private processTest(suite: TestSuiteResult, test: MochaJsonTest, result: TestExecutionResult): void { private processTest(suite: TestSuiteResult, test: MochaJsonTest, result: TestExecutionResult): void {
const groupName = const groupName =
test.fullTitle !== test.title test.fullTitle !== test.title
? test.fullTitle.substr(0, test.fullTitle.length - test.title.length).trimEnd() ? test.fullTitle.substring(0, test.fullTitle.length - test.title.length).trimEnd()
: null : null
let group = suite.groups.find(grp => grp.name === groupName) let group = suite.groups.find(grp => grp.name === groupName)
@@ -103,7 +103,7 @@ export class MochaJsonParser implements TestParser {
path = normalizeFilePath(path) path = normalizeFilePath(path)
const workDir = this.getWorkDir(path) const workDir = this.getWorkDir(path)
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length) path = path.substring(workDir.length)
} }
return path return path
} }

View File

@@ -208,7 +208,7 @@ export class PhpunitJunitParser implements TestParser {
path = normalizeFilePath(path) path = normalizeFilePath(path)
const workDir = this.getWorkDir(path) const workDir = this.getWorkDir(path)
if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
path = path.substr(workDir.length) path = path.substring(workDir.length)
} }
return path return path
} }

View File

@@ -55,7 +55,7 @@ export class RspecJsonParser implements TestParser {
private processTest(suite: TestSuiteResult, test: RspecExample, result: TestExecutionResult): void { private processTest(suite: TestSuiteResult, test: RspecExample, result: TestExecutionResult): void {
const groupName = const groupName =
test.full_description !== test.description test.full_description !== test.description
? test.full_description.substr(0, test.full_description.length - test.description.length).trimEnd() ? test.full_description.substring(0, test.full_description.length - test.description.length).trimEnd()
: null : null
let group = suite.groups.find(grp => grp.name === groupName) let group = suite.groups.find(grp => grp.name === groupName)

View File

@@ -36,7 +36,7 @@ export function ellipsis(text: string, maxLength: number): string {
return text return text
} }
return text.substr(0, maxLength - 3) + '...' return text.substring(0, maxLength - 3) + '...'
} }
export function formatTime(ms: number): string { export function formatTime(ms: number): string {

View File

@@ -34,6 +34,6 @@ export function getBasePath(path: string, trackedFiles: string[]): string | unde
return undefined return undefined
} }
const base = path.substr(0, path.length - max.length) const base = path.substring(0, path.length - max.length)
return base return base
} }