diff --git a/packages/T-E-M-P-L-A-T-E/package.json b/packages/T-E-M-P-L-A-T-E/package.json index 74ab828d..ed8e2ed8 100644 --- a/packages/T-E-M-P-L-A-T-E/package.json +++ b/packages/T-E-M-P-L-A-T-E/package.json @@ -14,7 +14,7 @@ "types": "dist/index.d.ts", "dependencies": { "@types/node": "^20.0.0", - "@salesforce/code-analyzer-engine-api": "0.3.0" + "@salesforce/code-analyzer-engine-api": "0.4.0" }, "devDependencies": { "@eslint/js": "^8.57.0", diff --git a/packages/code-analyzer-core/package.json b/packages/code-analyzer-core/package.json index 49b436cc..fbbacf53 100644 --- a/packages/code-analyzer-core/package.json +++ b/packages/code-analyzer-core/package.json @@ -1,7 +1,7 @@ { "name": "@salesforce/code-analyzer-core", "description": "Core Package for the Salesforce Code Analyzer", - "version": "0.3.0", + "version": "0.4.0", "author": "The Salesforce Code Analyzer Team", "license": "BSD-3-Clause license", "homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview", @@ -13,7 +13,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "dependencies": { - "@salesforce/code-analyzer-engine-api": "0.3.0", + "@salesforce/code-analyzer-engine-api": "0.4.0", "@types/js-yaml": "^4.0.9", "@types/node": "^20.0.0", "csv-stringify": "^6.5.0", diff --git a/packages/code-analyzer-core/src/code-analyzer.ts b/packages/code-analyzer-core/src/code-analyzer.ts index 1fd10ea8..52bd2dc1 100644 --- a/packages/code-analyzer-core/src/code-analyzer.ts +++ b/packages/code-analyzer-core/src/code-analyzer.ts @@ -16,8 +16,8 @@ import fs from "node:fs"; import path from "node:path"; export type RunOptions = { - filesToInclude: string[] - entryPoints?: string[] + workspaceFiles: string[] + pathStartPoints?: string[] } export class CodeAnalyzer { @@ -238,17 +238,17 @@ function validateRuleDescriptions(ruleDescriptions: engApi.RuleDescription[], en } function extractEngineRunOptions(runOptions: RunOptions): engApi.RunOptions { - if(!runOptions.filesToInclude || runOptions.filesToInclude.length == 0) { + if(!runOptions.workspaceFiles || runOptions.workspaceFiles.length == 0) { throw new Error(getMessage('AtLeastOneFileOrFolderMustBeIncluded')); } const engineRunOptions: engApi.RunOptions = { - filesToInclude: removeRedundantPaths(runOptions.filesToInclude.map(validateFileOrFolder)) + workspaceFiles: removeRedundantPaths(runOptions.workspaceFiles.map(validateFileOrFolder)) }; - if (runOptions.entryPoints && runOptions.entryPoints.length > 0) { - engineRunOptions.entryPoints = runOptions.entryPoints.flatMap(extractEngineEntryPoints) + if (runOptions.pathStartPoints && runOptions.pathStartPoints.length > 0) { + engineRunOptions.pathStartPoints = runOptions.pathStartPoints.flatMap(extractEnginePathStartPoints) } - validateEntryPointsLiveUnderFilesToInclude(engineRunOptions); + validatePathStartPointsAreInsideWorkspace(engineRunOptions); return engineRunOptions; } @@ -276,53 +276,53 @@ function validateFileOrFolder(fileOrFolder: string): string { return absFileOrFolder; } -function validateEntryPointFile(file: string, entryPointStr: string): string { +function validatePathStartPointFile(file: string, pathStartPointStr: string): string { const absFile: string = toAbsolutePath(file); if (!fs.existsSync(absFile)) { - throw new Error(getMessage('EntryPointFileDoesNotExist', entryPointStr, absFile)); + throw new Error(getMessage('PathStartPointFileDoesNotExist', pathStartPointStr, absFile)); } else if (fs.statSync(absFile).isDirectory()) { - throw new Error(getMessage('EntryPointWithMethodMustNotBeFolder', entryPointStr, absFile)); + throw new Error(getMessage('PathStartPointWithMethodMustNotBeFolder', pathStartPointStr, absFile)); } return absFile; } -function extractEngineEntryPoints(entryPointStr: string): engApi.EntryPoint[] { - const parts: string[] = entryPointStr.split('#'); +function extractEnginePathStartPoints(pathStartPointStr: string): engApi.PathPoint[] { + const parts: string[] = pathStartPointStr.split('#'); if (parts.length == 1) { return [{ - file: validateFileOrFolder(entryPointStr) + file: validateFileOrFolder(pathStartPointStr) }]; } else if (parts.length > 2) { - throw new Error(getMessage('InvalidEntryPoint', entryPointStr)); + throw new Error(getMessage('InvalidPathStartPoint', pathStartPointStr)); } - const entryPointFile: string = validateEntryPointFile(parts[0], entryPointStr); + const pathStartPointFile: string = validatePathStartPointFile(parts[0], pathStartPointStr); const VALID_METHOD_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_]*$/; const TRAILING_SPACES_AND_SEMICOLONS_REGEX = /\s+;*$/; const methodNames: string = parts[1].replace(TRAILING_SPACES_AND_SEMICOLONS_REGEX, ''); return methodNames.split(";").map(methodName => { if (! VALID_METHOD_NAME_REGEX.test(methodName) ) { - throw new Error(getMessage('InvalidEntryPoint', entryPointStr)); + throw new Error(getMessage('InvalidPathStartPoint', pathStartPointStr)); } - return { file: entryPointFile, methodName: methodName }; + return { file: pathStartPointFile, methodName: methodName }; }); } -function validateEntryPointsLiveUnderFilesToInclude(engineRunOptions: engApi.RunOptions) { - if (!engineRunOptions.entryPoints) { +function validatePathStartPointsAreInsideWorkspace(engineRunOptions: engApi.RunOptions) { + if (!engineRunOptions.pathStartPoints) { return; } - for (const engineEntryPoint of engineRunOptions.entryPoints) { - if (!fileIsUnderneath(engineEntryPoint.file, engineRunOptions.filesToInclude)) { - throw new Error(getMessage('EntryPointMustBeUnderFilesToInclude', engineEntryPoint.file, - JSON.stringify(engineRunOptions.filesToInclude))); + for (const enginePathStartPoint of engineRunOptions.pathStartPoints) { + if (!fileIsUnderneath(enginePathStartPoint.file, engineRunOptions.workspaceFiles)) { + throw new Error(getMessage('PathStartPointMustBeInsideWorkspace', enginePathStartPoint.file, + JSON.stringify(engineRunOptions.workspaceFiles))); } } } -function fileIsUnderneath(entryPointFile: string, filesOrFolders: string[]): boolean { - return filesOrFolders.some(fileOrFolder => fileOrFolder == entryPointFile || - (fs.statSync(fileOrFolder).isDirectory() && entryPointFile.startsWith(fileOrFolder))); +function fileIsUnderneath(file: string, filesOrFolders: string[]): boolean { + return filesOrFolders.some(fileOrFolder => fileOrFolder == file || + (fs.statSync(fileOrFolder).isDirectory() && file.startsWith(fileOrFolder))); } function validateEngineRunResults(engineName: string, apiEngineRunResults: engApi.EngineRunResults, ruleSelection: RuleSelection): void { diff --git a/packages/code-analyzer-core/src/messages.ts b/packages/code-analyzer-core/src/messages.ts index 7d31a83e..7da0d47b 100644 --- a/packages/code-analyzer-core/src/messages.ts +++ b/packages/code-analyzer-core/src/messages.ts @@ -70,17 +70,17 @@ const messageCatalog : { [key: string]: string } = { AtLeastOneFileOrFolderMustBeIncluded: 'At least one file or folder must be included.', - EntryPointFileDoesNotExist: - 'The value "%s" is not a valid entry point since the file "%s" does not exist.', + PathStartPointFileDoesNotExist: + 'The value "%s" is not a valid path starting point since the file "%s" does not exist.', - EntryPointWithMethodMustNotBeFolder: - 'The value "%s" is not a valid entry point since "%s" is a folder instead of a file.', + PathStartPointWithMethodMustNotBeFolder: + 'The value "%s" is not a valid path starting point since "%s" is a folder instead of a file.', - InvalidEntryPoint: - `The value "%s" is not a valid entry point. Expected value to be of the format "", "#", or "#;;...".`, + InvalidPathStartPoint: + `The value "%s" is not a valid path starting point. Expected value to be of the format "", "#", or "#;;...".`, - EntryPointMustBeUnderFilesToInclude: - 'The specified entry point of "%s" does not that exists underneath any of the specified paths: %s', + PathStartPointMustBeInsideWorkspace: + 'The specified path starting point of "%s" does not that exists underneath any of the specified paths: %s', RunningWithRunOptions: 'Running with the following run options: %s', @@ -121,7 +121,7 @@ const messageCatalog : { [key: string]: string } = { } /** - * getMessage - This is the main entry point to get a message out of the message catalog. + * getMessage - This is the main function to get a message out of the message catalog. * @param msgId - The message identifier * @param args - The arguments that will fill in the %s and %d markers. */ diff --git a/packages/code-analyzer-core/test/output-format.test.ts b/packages/code-analyzer-core/test/output-format.test.ts index eef98bbe..93844329 100644 --- a/packages/code-analyzer-core/test/output-format.test.ts +++ b/packages/code-analyzer-core/test/output-format.test.ts @@ -19,7 +19,7 @@ beforeAll(async () => { (stubPlugin.getCreatedEngine('stubEngine2') as stubs.StubEngine2).resultsToReturn = { violations: [stubs.getSampleViolationForStub2RuleC()] }; - runResults = await codeAnalyzer.run(codeAnalyzer.selectRules('all'), {filesToInclude: ['test']}); + runResults = await codeAnalyzer.run(codeAnalyzer.selectRules('all'), {workspaceFiles: ['test']}); }); describe("Tests for the CSV output format", () => { @@ -123,5 +123,5 @@ function getContentsOfExpectedOutputFile(expectedOutputFileName: string, escapeB async function createResultsWithUnexpectedError(): Promise { const codeAnalyzer: CodeAnalyzer = new CodeAnalyzer(CodeAnalyzerConfig.withDefaults()); await codeAnalyzer.addEnginePlugin(new stubs.ThrowingEnginePlugin()); - return codeAnalyzer.run(codeAnalyzer.selectRules(), {filesToInclude: ['test']}); + return codeAnalyzer.run(codeAnalyzer.selectRules(), {workspaceFiles: ['test']}); } \ No newline at end of file diff --git a/packages/code-analyzer-core/test/run.test.ts b/packages/code-analyzer-core/test/run.test.ts index 46c4f72e..b7225a91 100644 --- a/packages/code-analyzer-core/test/run.test.ts +++ b/packages/code-analyzer-core/test/run.test.ts @@ -26,7 +26,7 @@ import {UnexpectedEngineErrorRule} from "../src/rules"; import {UndefinedCodeLocation} from "../src/results"; const SAMPLE_RUN_OPTIONS: RunOptions = { - filesToInclude: ['test'] + workspaceFiles: ['test'] }; describe("Tests for the run method of CodeAnalyzer", () => { @@ -56,87 +56,87 @@ describe("Tests for the run method of CodeAnalyzer", () => { it("When run options contains file that does not exist, then error", () => { const runOptions: RunOptions = { - filesToInclude: ['does/not/exist.cls'] + workspaceFiles: ['does/not/exist.cls'] }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( getMessage('FileOrFolderDoesNotExist', toAbsolutePath('does/not/exist.cls'))); }); - it("When run options contains entrypoint (without method) with a file that does not exist, then error", () => { + it("When run options contains a path start point (without method) with a file that does not exist, then error", () => { const runOptions: RunOptions = { - filesToInclude: [path.resolve(__dirname)], - entryPoints: [path.resolve(__dirname, 'doesNotExist.xml')], + workspaceFiles: [path.resolve(__dirname)], + pathStartPoints: [path.resolve(__dirname, 'doesNotExist.xml')], }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( getMessage('FileOrFolderDoesNotExist', path.resolve(__dirname, 'doesNotExist.xml'))); }); - it("When run options contains entrypoint (with method) with a file that does not exist, then error", () => { - const badEntryPoint: string = path.resolve(__dirname, 'doesNotExist.xml#someMethod'); + it("When run options contains a path start point (with method) with a file that does not exist, then error", () => { + const badPathStartPoint: string = path.resolve(__dirname, 'doesNotExist.xml#someMethod'); const runOptions: RunOptions = { - filesToInclude: [path.resolve(__dirname)], - entryPoints: [path.resolve(__dirname, 'run.test.ts'), badEntryPoint] + workspaceFiles: [path.resolve(__dirname)], + pathStartPoints: [path.resolve(__dirname, 'run.test.ts'), badPathStartPoint] }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( - getMessage('EntryPointFileDoesNotExist', badEntryPoint, path.resolve(__dirname, 'doesNotExist.xml'))); + getMessage('PathStartPointFileDoesNotExist', badPathStartPoint, path.resolve(__dirname, 'doesNotExist.xml'))); }); - it("When entry point is a folder with methods specified, then error", () => { - const badEntryPoint: string = "test/test-data#method1;method2"; + it("When path starting point is a folder with methods specified, then error", () => { + const badPathStartPoint: string = "test/test-data#method1;method2"; const runOptions: RunOptions = { - filesToInclude: [path.resolve(__dirname)], - entryPoints: [badEntryPoint], + workspaceFiles: [path.resolve(__dirname)], + pathStartPoints: [badPathStartPoint], }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( - getMessage('EntryPointWithMethodMustNotBeFolder', badEntryPoint, path.resolve('test', 'test-data'))); + getMessage('PathStartPointWithMethodMustNotBeFolder', badPathStartPoint, path.resolve('test', 'test-data'))); }); - it("When entry point has too many hashtags specified, then error", () => { - const badEntryPoint: string = "test/test-helpers.ts#method1#method2"; + it("When path starting point has too many hashtags specified, then error", () => { + const badPathStartPoint: string = "test/test-helpers.ts#method1#method2"; const runOptions: RunOptions = { - filesToInclude: ['test'], - entryPoints: [badEntryPoint], + workspaceFiles: ['test'], + pathStartPoints: [badPathStartPoint], }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( - getMessage('InvalidEntryPoint', badEntryPoint)); + getMessage('InvalidPathStartPoint', badPathStartPoint)); }); - it("When specifying an entry point that has an invalid character in its method name, then error", () => { - const badEntryPoint: string = "test/test-helpers.ts#someMethod,oopsCommaIsInvalidHere"; + it("When specifying a path starting point that has an invalid character in its method name, then error", () => { + const badPathStartPoint: string = "test/test-helpers.ts#someMethod,oopsCommaIsInvalidHere"; const runOptions: RunOptions = { - filesToInclude: ['test'], - entryPoints: [badEntryPoint], + workspaceFiles: ['test'], + pathStartPoints: [badPathStartPoint], }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( - getMessage('InvalidEntryPoint', badEntryPoint)); + getMessage('InvalidPathStartPoint', badPathStartPoint)); }); it("When files to include is an empty array, then error", () => { const runOptions: RunOptions = { - filesToInclude: [] + workspaceFiles: [] }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( getMessage('AtLeastOneFileOrFolderMustBeIncluded')); }); - it("When entry point does not live under one of the specified paths, then error", () => { - const badEntryPoint: string = "test/test-helpers.ts#someMethod"; + it("When path start point does not live under one of the specified paths, then error", () => { + const badPathStartPoint: string = "test/test-helpers.ts#someMethod"; const runOptions: RunOptions = { - filesToInclude: ['src', 'package.json'], - entryPoints: [badEntryPoint], + workspaceFiles: ['src', 'package.json'], + pathStartPoints: [badPathStartPoint], }; expect(codeAnalyzer.run(selection, runOptions)).rejects.toThrow( - getMessage('EntryPointMustBeUnderFilesToInclude', path.resolve('test', 'test-helpers.ts'), + getMessage('PathStartPointMustBeInsideWorkspace', path.resolve('test', 'test-helpers.ts'), JSON.stringify([path.resolve('package.json'), path.resolve('src')]))); }); it("When including a relative file and a folder then they both are passed each engine as absolute paths", async () => { await codeAnalyzer.run(selection, { - filesToInclude: ['src', 'test/run.test.ts'] + workspaceFiles: ['src', 'test/run.test.ts'] }); const expectedEngineRunOptions: engApi.RunOptions = { - filesToInclude: [path.resolve('src'), path.resolve('test', 'run.test.ts')] + workspaceFiles: [path.resolve('src'), path.resolve('test', 'run.test.ts')] }; expect(stubEngine1.runRulesCallHistory).toEqual([{ ruleNames: expectedStubEngine1RuleNames, @@ -150,11 +150,11 @@ describe("Tests for the run method of CodeAnalyzer", () => { it("When including a parent folder and child paths under that folder, then the redundant children are removed", async () => { await codeAnalyzer.run(selection, { - filesToInclude: ['test/test-data', 'test', 'test/run.test.ts'] + workspaceFiles: ['test/test-data', 'test', 'test/run.test.ts'] }); const expectedEngineRunOptions: engApi.RunOptions = { - filesToInclude: [path.resolve('test')] + workspaceFiles: [path.resolve('test')] }; expect(stubEngine1.runRulesCallHistory).toEqual([{ ruleNames: expectedStubEngine1RuleNames, @@ -166,14 +166,14 @@ describe("Tests for the run method of CodeAnalyzer", () => { }]); }); - it("When specifying entry points as an empty array, then no entry points are passed to engines", async () => { + it("When specifying path start points as an empty array, then no path start points are passed to engines", async () => { await codeAnalyzer.run(selection, { - filesToInclude: ['src'], - entryPoints: [] + workspaceFiles: ['src'], + pathStartPoints: [] }); const expectedEngineRunOptions: engApi.RunOptions = { - filesToInclude: [path.resolve('src')] + workspaceFiles: [path.resolve('src')] }; expect(stubEngine1.runRulesCallHistory).toEqual([{ ruleNames: expectedStubEngine1RuleNames, @@ -185,15 +185,15 @@ describe("Tests for the run method of CodeAnalyzer", () => { }]); }); - it("When specifying entry points as files and subfolders, then they are passed to each engine successfully", async () => { + it("When specifying path start points as files and subfolders, then they are passed to each engine successfully", async () => { await codeAnalyzer.run(selection, { - filesToInclude: ['test'], - entryPoints: ['test/test-data', 'test/run.test.ts'] + workspaceFiles: ['test'], + pathStartPoints: ['test/test-data', 'test/run.test.ts'] }); const expectedEngineRunOptions: engApi.RunOptions = { - filesToInclude: [path.resolve('test')], - entryPoints: [ + workspaceFiles: [path.resolve('test')], + pathStartPoints: [ { file: path.resolve("test", "test-data") }, { file: path.resolve("test", "run.test.ts")} ] @@ -208,15 +208,15 @@ describe("Tests for the run method of CodeAnalyzer", () => { }]); }); - it("When specifying entry points individual methods, then they are passed to each engine successfully", async () => { + it("When specifying path start points individual methods, then they are passed to each engine successfully", async () => { await codeAnalyzer.run(selection, { - filesToInclude: ['test', 'src/utils.ts', 'src/index.ts'], - entryPoints: ['test/run.test.ts#someMethod','test/stubs.ts#method1;method2;method3','src/utils.ts'] + workspaceFiles: ['test', 'src/utils.ts', 'src/index.ts'], + pathStartPoints: ['test/run.test.ts#someMethod','test/stubs.ts#method1;method2;method3','src/utils.ts'] }); const expectedEngineRunOptions: engApi.RunOptions = { - filesToInclude: [path.resolve("src", "index.ts"), path.resolve("src", "utils.ts"), path.resolve('test')], - entryPoints: [ + workspaceFiles: [path.resolve("src", "index.ts"), path.resolve("src", "utils.ts"), path.resolve('test')], + pathStartPoints: [ { file: path.resolve("test", "run.test.ts"), methodName: 'someMethod' @@ -253,7 +253,7 @@ describe("Tests for the run method of CodeAnalyzer", () => { codeAnalyzer.run(selection, SAMPLE_RUN_OPTIONS); const expectedEngineRunOptions: engApi.RunOptions = { - filesToInclude: [path.resolve('test')] + workspaceFiles: [path.resolve('test')] }; expect(stubEngine1.runRulesCallHistory).toEqual([{ ruleNames: expectedStubEngine1RuleNames, diff --git a/packages/code-analyzer-engine-api/package.json b/packages/code-analyzer-engine-api/package.json index 4e993b72..9d713b28 100644 --- a/packages/code-analyzer-engine-api/package.json +++ b/packages/code-analyzer-engine-api/package.json @@ -1,7 +1,7 @@ { "name": "@salesforce/code-analyzer-engine-api", "description": "Engine API Package for the Salesforce Code Analyzer", - "version": "0.3.0", + "version": "0.4.0", "author": "The Salesforce Code Analyzer Team", "license": "BSD-3-Clause license", "homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview", diff --git a/packages/code-analyzer-engine-api/src/engines.ts b/packages/code-analyzer-engine-api/src/engines.ts index 6313cc88..5540e0b4 100644 --- a/packages/code-analyzer-engine-api/src/engines.ts +++ b/packages/code-analyzer-engine-api/src/engines.ts @@ -3,14 +3,14 @@ import { EngineRunResults } from "./results"; import { Event } from "./events"; import { EventEmitter } from "node:events"; -export type EntryPoint = { +export type PathPoint = { file: string methodName?: string } export type RunOptions = { - filesToInclude: string[] - entryPoints?: EntryPoint[] + workspaceFiles: string[] + pathStartPoints?: PathPoint[] } export abstract class Engine { diff --git a/packages/code-analyzer-engine-api/src/index.ts b/packages/code-analyzer-engine-api/src/index.ts index 9772469d..9c421a85 100644 --- a/packages/code-analyzer-engine-api/src/index.ts +++ b/packages/code-analyzer-engine-api/src/index.ts @@ -8,7 +8,7 @@ export { export { Engine, - EntryPoint, + PathPoint, RunOptions } from "./engines" diff --git a/packages/code-analyzer-engine-api/test/api-v1.test.ts b/packages/code-analyzer-engine-api/test/api-v1.test.ts index fbda6237..8851e39f 100644 --- a/packages/code-analyzer-engine-api/test/api-v1.test.ts +++ b/packages/code-analyzer-engine-api/test/api-v1.test.ts @@ -32,7 +32,7 @@ describe('Tests for v1', () => { }); await dummyEngine.runRules(["dummy"], { - filesToInclude: ["some/file"] + workspaceFiles: ["some/file"] }); expect(logEvents).toHaveLength(1); diff --git a/packages/code-analyzer-eslint-engine/package.json b/packages/code-analyzer-eslint-engine/package.json index 6a3b643b..af104c76 100644 --- a/packages/code-analyzer-eslint-engine/package.json +++ b/packages/code-analyzer-eslint-engine/package.json @@ -14,7 +14,7 @@ "types": "dist/index.d.ts", "dependencies": { "@types/node": "^20.0.0", - "@salesforce/code-analyzer-engine-api": "0.3.0" + "@salesforce/code-analyzer-engine-api": "0.4.0" }, "devDependencies": { "@eslint/js": "^8.57.0", diff --git a/packages/code-analyzer-retirejs-engine/package.json b/packages/code-analyzer-retirejs-engine/package.json index efb8b633..933b7f63 100644 --- a/packages/code-analyzer-retirejs-engine/package.json +++ b/packages/code-analyzer-retirejs-engine/package.json @@ -13,7 +13,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "dependencies": { - "@salesforce/code-analyzer-engine-api": "0.3.0", + "@salesforce/code-analyzer-engine-api": "0.4.0", "@types/node": "^20.0.0", "@types/tmp": "^0.2.6", "isbinaryfile": "^5.0.2", diff --git a/packages/code-analyzer-retirejs-engine/src/engine.ts b/packages/code-analyzer-retirejs-engine/src/engine.ts index 2b61b8be..3f96d06e 100644 --- a/packages/code-analyzer-retirejs-engine/src/engine.ts +++ b/packages/code-analyzer-retirejs-engine/src/engine.ts @@ -63,7 +63,7 @@ export class RetireJsEngine extends Engine { } async runRules(ruleNames: string[], runOptions: RunOptions): Promise { - const findings: Finding[] = await this.retireJsExecutor.execute(runOptions.filesToInclude); + const findings: Finding[] = await this.retireJsExecutor.execute(runOptions.workspaceFiles); return { violations: toViolations(findings).filter(v => ruleNames.includes(v.ruleName)) }; diff --git a/packages/code-analyzer-retirejs-engine/src/messages.ts b/packages/code-analyzer-retirejs-engine/src/messages.ts index 13af3c35..31a6c26e 100644 --- a/packages/code-analyzer-retirejs-engine/src/messages.ts +++ b/packages/code-analyzer-retirejs-engine/src/messages.ts @@ -31,7 +31,7 @@ const messageCatalog : { [key: string]: string } = { } /** - * getMessage - This is the main entry point to get a message out of the message catalog. + * getMessage - This is the main function to get a message out of the message catalog. * @param msgId - The message identifier * @param args - The arguments that will fill in the %s and %d markers. */ diff --git a/packages/code-analyzer-retirejs-engine/test/end-to-end.test.ts b/packages/code-analyzer-retirejs-engine/test/end-to-end.test.ts index 2d806cf8..c298458e 100644 --- a/packages/code-analyzer-retirejs-engine/test/end-to-end.test.ts +++ b/packages/code-analyzer-retirejs-engine/test/end-to-end.test.ts @@ -20,7 +20,7 @@ describe('End to end test', () => { expect(ruleDescriptions).toHaveLength(4); const ruleNames: string[] = ruleDescriptions.map(rd => rd.name); const engineRunResults: EngineRunResults = await engine.runRules(ruleNames, { - filesToInclude: [ + workspaceFiles: [ path.resolve('test', 'test-data', 'scenarios', '1_hasJsLibraryWithVulnerability'), // Expect 3 violations: 1 file with 3 vulnerabilities path.resolve('test', 'test-data', 'scenarios', '6_hasVulnerableResourceAndZipFiles', 'ZipFileAsResource.resource'), // Expect 6 violations: 2 files each with 3 vulnerabilities ] diff --git a/packages/code-analyzer-retirejs-engine/test/engine.test.ts b/packages/code-analyzer-retirejs-engine/test/engine.test.ts index 4858e660..57100b91 100644 --- a/packages/code-analyzer-retirejs-engine/test/engine.test.ts +++ b/packages/code-analyzer-retirejs-engine/test/engine.test.ts @@ -157,8 +157,8 @@ describe('Tests for the RetireJsEngine', () => { const allRuleNames: string[] = (await engine.describeRules()).map(r => r.name); const filesAndFoldersToScan: string[] = [path.resolve('build-tools'), path.resolve('test/test-helpers.ts')]; const runOptions: RunOptions = { - filesToInclude: filesAndFoldersToScan, - entryPoints: [{file: 'test/test-helpers.ts'}] // Sanity check that this should be ignored by this engine + workspaceFiles: filesAndFoldersToScan, + pathStartPoints: [{file: 'test/test-helpers.ts'}] // Sanity check that this should be ignored by this engine }; const results: EngineRunResults = await engine.runRules(allRuleNames, runOptions); @@ -168,7 +168,7 @@ describe('Tests for the RetireJsEngine', () => { it('When using all rules and violations are found, then the engine correctly returns the results', async () => { const allRuleNames: string[] = (await engine.describeRules()).map(r => r.name); - const engineRunResults: EngineRunResults = await engine.runRules(allRuleNames, {filesToInclude: ['dummy']}); + const engineRunResults: EngineRunResults = await engine.runRules(allRuleNames, {workspaceFiles: ['dummy']}); expect(engineRunResults.violations).toHaveLength(4); expect(engineRunResults.violations[0]).toEqual(EXPECTED_VIOLATION_1); @@ -180,21 +180,21 @@ describe('Tests for the RetireJsEngine', () => { it('When only selecting some rules, then only violations for those rules are returned', async () => { const engineRunResults1: EngineRunResults = await engine.runRules( ['LibraryWithKnownHighSeverityVulnerability', 'LibraryWithKnownLowSeverityVulnerability'], - {filesToInclude: ['dummy']}); + {workspaceFiles: ['dummy']}); expect(engineRunResults1).toEqual({ violations: [EXPECTED_VIOLATION_3, EXPECTED_VIOLATION_4] }); const engineRunResults2: EngineRunResults = await engine.runRules( ['LibraryWithKnownMediumSeverityVulnerability', 'LibraryWithKnownCriticalSeverityVulnerability'], - {filesToInclude: ['dummy']}); + {workspaceFiles: ['dummy']}); expect(engineRunResults2).toEqual({ violations: [EXPECTED_VIOLATION_1, EXPECTED_VIOLATION_2] }); const engineRunResults3: EngineRunResults = await engine.runRules( - ['LibraryWithKnownCriticalSeverityVulnerability'], {filesToInclude: ['dummy']}); + ['LibraryWithKnownCriticalSeverityVulnerability'], {workspaceFiles: ['dummy']}); expect(engineRunResults3).toEqual({violations: []}); }); });