From 70b3103fe010ccd03cef7b396179f6d747cf73cb Mon Sep 17 00:00:00 2001 From: Joshua Feingold Date: Wed, 11 Dec 2024 14:39:25 -0600 Subject: [PATCH] @W-17397558@ Integrated feedback from code review --- .../verify-pr/validate-changed-package-versions.js | 4 +++- packages/code-analyzer-core/src/code-analyzer.ts | 6 +++++- packages/code-analyzer-core/src/messages.ts | 2 +- packages/code-analyzer-core/test/code-analyzer.test.ts | 1 - 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/verify-pr/validate-changed-package-versions.js b/.github/workflows/verify-pr/validate-changed-package-versions.js index c93e7b52..4e6b920b 100644 --- a/.github/workflows/verify-pr/validate-changed-package-versions.js +++ b/.github/workflows/verify-pr/validate-changed-package-versions.js @@ -62,7 +62,9 @@ function convertFileNameToPackageNameIfPossible(changedFile) { function isFileInTestFolder(changedFile) { const changedFilePathSegments = path.dirname(changedFile).split('/'); - return changedFilePathSegments.includes('test'); + return changedFilePathSegments.length >= 3 + && changedFilePathSegments[0] === 'packages' + && changedFilePathSegments[2] === 'test'; } function identifyIncorrectlyVersionedPackages(changedPackages) { diff --git a/packages/code-analyzer-core/src/code-analyzer.ts b/packages/code-analyzer-core/src/code-analyzer.ts index 1ff6770a..18b4029e 100644 --- a/packages/code-analyzer-core/src/code-analyzer.ts +++ b/packages/code-analyzer-core/src/code-analyzer.ts @@ -52,11 +52,15 @@ export class CodeAnalyzer { private readonly engineRuleDiscoveryProgressAggregator: EngineProgressAggregator = new EngineProgressAggregator(); constructor(config: CodeAnalyzerConfig, version: string = process.version) { + this.validateEnviroment(version); + this.config = config; + } + + private validateEnviroment(version: string): void { const semver: SemVer = new SemVer(version); if (semver.major < MINIMUM_SUPPORTED_NODE) { throw new Error(getMessage('UnsupportedNodeVersion', MINIMUM_SUPPORTED_NODE, version)); } - this.config = config; } // For testing purposes only diff --git a/packages/code-analyzer-core/src/messages.ts b/packages/code-analyzer-core/src/messages.ts index 233c9cd2..1f64bca7 100644 --- a/packages/code-analyzer-core/src/messages.ts +++ b/packages/code-analyzer-core/src/messages.ts @@ -40,7 +40,7 @@ const MESSAGE_CATALOG : MessageCatalog = { `%s ENGINE CONFIGURATION`, UnsupportedNodeVersion: - `Code Analyzer requires Node v%s or later. Current Node version: %s`, + `Code Analyzer requires Node v%s or later, but is currently running on Node %s. Please upgrade the version of 'node' on your machine.`, EngineConfigFieldDescription_disable_engine: `Whether to turn off the '%s' engine so that it is not included when running Code Analyzer commands.`, diff --git a/packages/code-analyzer-core/test/code-analyzer.test.ts b/packages/code-analyzer-core/test/code-analyzer.test.ts index e550e3b2..87ae0459 100644 --- a/packages/code-analyzer-core/test/code-analyzer.test.ts +++ b/packages/code-analyzer-core/test/code-analyzer.test.ts @@ -55,7 +55,6 @@ describe("Tests for the run method of CodeAnalyzer", () => { const expectedStubEngine2RuleNames: string[] = ['stub2RuleA', 'stub2RuleC']; beforeEach(async () => { - jest.mock('process') sampleTimestamp = new Date(); codeAnalyzer = new CodeAnalyzer(CodeAnalyzerConfig.withDefaults()); codeAnalyzer._setClock(new FixedClock(sampleTimestamp));