Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/publish-package-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ on:
type: boolean
required: false
default: false
code-analyzer-flow-analyzer-engine:
description: Should the code-analyzer-flow-analyzer-engine package be released?
type: boolean
required: false
default: false
dryrun:
description: Add --dry-run to npm publish step? (Uncheck to actually publish)
type: boolean
Expand Down Expand Up @@ -118,6 +123,9 @@ jobs:
if [ "${{ inputs.code-analyzer-uibundle-engine }}" == "true" ]; then
PACKAGES_TO_CHECK_ARR+=('code-analyzer-uibundle-engine')
fi
if [ "${{ inputs.code-analyzer-flow-analyzer-engine }}" == "true" ]; then
PACKAGES_TO_CHECK_ARR+=('code-analyzer-flow-analyzer-engine')
fi
PACKAGES_TO_CHECK_STR=$(IFS=' '; echo "${PACKAGES_TO_CHECK_ARR[*]}")
node ./.github/workflows/publish-package-to-npm/validate-packages-as-releasable.js "$PACKAGES_TO_CHECK_STR"
echo "packages_to_release=$PACKAGES_TO_CHECK_STR" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 2 additions & 0 deletions .node-scripts/validate-changed-package-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ function getLatestReleasedVersion(changedPackage) {
function isPackageThatHasNotPublished(changedPackage) {
return [
"packages/ENGINE-TEMPLATE",
// TODO: remove once @salesforce/code-analyzer-flow-analyzer-engine is published to npm
"packages/code-analyzer-flow-analyzer-engine",
].includes(changedPackage.replace("\\","/"));
}

Expand Down
268 changes: 264 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/code-analyzer-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/code-analyzer-core",
"description": "Core Package for the Salesforce Code Analyzer",
"version": "0.53.0",
"version": "0.54.0-SNAPSHOT",
"author": "The Salesforce Code Analyzer Team",
"license": "BSD-3-Clause",
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
Expand Down
26 changes: 24 additions & 2 deletions packages/code-analyzer-core/src/code-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export class CodeAnalyzer {
selectors = selectors.length > 0 ? selectors : [engApi.COMMON_TAGS.RECOMMENDED];
const selectorObjects: Selector[] = selectors.map(toSelector);

const allRules: RuleImpl[] = await this.getAllRules(selectOptions?.workspace);
const allRules: RuleImpl[] = await this.getAllRules(selectOptions?.workspace, selectors);

const ruleSelection: RuleSelectionImpl = new RuleSelectionImpl();
const disabledRules: {ruleName: string, engineName: string}[] = [];
Expand Down Expand Up @@ -599,7 +599,7 @@ export class CodeAnalyzer {
this.eventEmitter.on(eventType, callback);
}

private async getAllRules(workspace?: Workspace): Promise<RuleImpl[]> {
private async getAllRules(workspace?: Workspace, selectors?: string[]): Promise<RuleImpl[]> {
const cacheKey: string = workspace ? workspace.getWorkspaceId() : process.cwd();
if (!this.rulesCache.has(cacheKey)) {
this.engineRuleDiscoveryProgressAggregator.reset(this.getEngineNames());
Expand All @@ -609,6 +609,11 @@ export class CodeAnalyzer {
await this.tempFolder.makeSubfolder(rulesWorkingFolderName);

const rulePromises: Promise<RuleImpl[]>[] = this.getEngineNames().map(async (engineName) => {
// Skip opt-in engines (flow-analyzer) if they're not explicitly in the selector
if (this.isOptInEngineNotInSelector(engineName, selectors)) {
this.emitLogEvent(LogLevel.Debug, getMessage('SkippingOptInEngine', engineName));
return [];
}
const workingFolder: string = await this.tempFolder.makeSubfolder(rulesWorkingFolderName, engineName);

if (this.config.getPreserveAllWorkingFolders()) {
Expand Down Expand Up @@ -869,6 +874,23 @@ export class CodeAnalyzer {
private getEngine(engineName: string): engApi.Engine {
return this.engines.get(engineName)!;
}

private isOptInEngineNotInSelector(engineName: string, selectors?: string[]): boolean {
// Flow Analyzer is an opt-in engine that should only be instantiated if explicitly requested
if (engineName !== 'flow-analyzer') {
return false;
}
// If selectors are provided, check if this engine is explicitly in any selector
if (selectors && selectors.length > 0) {
const selectorsLower = selectors.map(s => s.toLowerCase());
return !selectorsLower.some(s =>
s === 'flow-analyzer' ||
s.includes('flow-analyzer')
);
}
// If no selectors provided (shouldn't happen, but be safe), don't skip
return false;
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/code-analyzer-core/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ const MESSAGE_CATALOG : MessageCatalog = {
GatheringRulesFromEngine:
`Gathering all available rules from engine '%s'.`,

SkippingOptInEngine:
`Skipping opt-in engine '%s' because it was not explicitly selected.`,

FinishedGatheringRulesFromEngine:
`Finished gathering %d available rule(s) from engine '%s'.`,

Expand Down
Loading