Skip to content

Integrate the Flow Analyzer engine into the Code Analyzer CLI - #2105

Open
antoinesfdc wants to merge 3 commits into
forcedotcom:devfrom
antoinesfdc:flowanalyzer-engine
Open

antoinesfdc wants to merge 3 commits into
forcedotcom:devfrom
antoinesfdc:flowanalyzer-engine

Conversation

@antoinesfdc

Copy link
Copy Markdown

Summary
Registers the new @salesforce/code-analyzer-flowanalyzer-engine in the CLI and makes it usable from the command line. The engine sends targeted Flow metadata to a Salesforce org for remote analysis. It lives in code-analyzer-core (packages/code-analyzer-flowanalyzer-engine, on the matching flowanalyzer-engine branch).
Changes
Engine registration
- package.json and package-lock.json add the code-analyzer-flowanalyzer-engine dependency.
EnginePluginsFactory adds the engine to the plugin list.
--target-org / -o flag on code-analyzer rules

  • rules previously had no org flag. Listing Flow Analyzer rules needs an authenticated org, because the catalog comes from the remote service.
  • RulesAction passes the value to the config factory as a CLI override.
  • Config override
  • CodeAnalyzerConfigFactory now applies
    -target-org to engines.flowAnalyzer.target_org as well as engines.apexguru.target_org.
  • This also covers the case where no confia file is given.
  • Help text
  • rules-command.md and run-command.md have new --target-org docs and examples.
  • The examples show listing rules, and running against specific flows by path or glob. Only targeted flows are sent to the org.
    Tests
  • Updated rules, RulesAction, CodeAnalyzerConfigFactory and EnginePluginsFactory tests cover the new flag, the override and the engine registration.
    Notes for reviewers
  • The engine dependency is a local file:../code-analyzer-core/packages/code-analyzer-flowanalyzer-engine reference. It must change to a published version before release.
  • Flow Analyzer needs a target org, from --target-org or engines.flowAnalyzer.target_org in code-analyzer.yml. Other engines ignore the flag.

Adds @salesforce/code-analyzer-flowanalyzer-engine as a dependency, registers it
in EnginePluginsFactory, and updates CodeAnalyzerConfigFactory, RulesAction and
the rules command accordingly. Updates the rules/run command messages, adds a
sample code-analyzer.yml that toggles engines, and updates the related tests.
ApexGuruEngineModule.createEnginePlugin(),
UIBundleEngineModule.createEnginePlugin()
UIBundleEngineModule.createEnginePlugin(),
FlowAnalyzerEngineModule.createEnginePlugin()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Do not make every existing scan fail without a target org

This plugin is registered for every invocation, but the matching Core PR rejects a missing engines.flowAnalyzer.target_org while createEngineConfig() runs. Core records that as an uninstantiable engine, and CodeAnalyzer.run() appends an UninstantiableEngineRunResults for every such engine regardless of the selected rules. Consequently an existing command such as sf code-analyzer run --rule-selector eslint with no --target-org gains a critical Flow Analyzer error. Please make the engine opt-in/disabled when no org is configured, or defer the target-org requirement so unrelated scans remain unchanged.

Comment thread package.json
"@salesforce/code-analyzer-engine-api": "0.42.0",
"@salesforce/code-analyzer-eslint-engine": "0.47.0",
"@salesforce/code-analyzer-flow-engine": "0.41.0",
"@salesforce/code-analyzer-flowanalyzer-engine": "file:../code-analyzer-core/packages/code-analyzer-flowanalyzer-engine",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Replace the repository-external file dependency before merging

This link only resolves when code-analyzer-core happens to be checked out as a sibling directory. A normal standalone clone, npm ci, or packaged/published plugin has no ../code-analyzer-core/packages/code-analyzer-flowanalyzer-engine, and the lockfile also records this as a symlink, so installation cannot reproduce the dependency. This needs to reference a published/packageable version before the PR lands, not merely before a later release.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs the project to be build by npm first isn't it ?

Runs the real engine plugins with no target org and checks that unrelated
scans report no flowAnalyzer errors and that flowAnalyzer offers no rules.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants