Skip to content

Commit

Permalink
@W-17397558@ Integrated feedback from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeingold35 committed Dec 11, 2024
1 parent a29d672 commit 70b3103
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion packages/code-analyzer-core/src/code-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/code-analyzer-core/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand Down
1 change: 0 additions & 1 deletion packages/code-analyzer-core/test/code-analyzer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 70b3103

Please sign in to comment.