Skip to content

[W-22393672] Expose ApexGuru engine in CLI with --target-org flag#2051

Open
nikhil-mittal-165 wants to merge 3 commits into
devfrom
feature/W-22393676-apexguru-cli-integration
Open

[W-22393672] Expose ApexGuru engine in CLI with --target-org flag#2051
nikhil-mittal-165 wants to merge 3 commits into
devfrom
feature/W-22393676-apexguru-cli-integration

Conversation

@nikhil-mittal-165

Copy link
Copy Markdown
Contributor

Summary

Integrates the ApexGuru engine into the Code Analyzer CLI. Adds a --target-org flag to sf code-analyzer run so users can run Apex anti-pattern analysis against an authenticated org.

GUS Ticket

W-22393672 — code-analyzer | Expose ApexGuru engine in CLI with --target-org flag

Changes

  • Add --target-org flag to sf code-analyzer run command (standard SF CLI org flag pattern)
  • Register ApexGuru as an engine in EnginePluginsFactory
  • Wire target-org config through RunAction to engine config (passes alias/username string only — core resolves credentials internally via @salesforce/core)
  • Add end-to-end tests for --target-org flag
  • Fix test stubs for getInsights and getEngineInsights

Dependencies

Test Evidence

  • Unit tests: 384/386 pass
  • Integration: sf code-analyzer run finds 1224 violations on dreamhouse
  • ApexGuru workspace scan completes (65.97% progress on large codebases before 120s timeout)

Test Status: PASS

Findings Doc

https://docs.google.com/document/d/1zNU-LaHOZIEfGDVHlk5-9MpuCucKEEAseQglyF0bDWk/edit

Add --target-org/-o flag to code-analyzer run command to specify
target Salesforce org for remote analysis engines like ApexGuru.

Changes:
- Add target-org flag to RunCommand with char 'o'
- Update RunInput type to include optional target-org field
- Add ApexGuru engine dependency from feature branch
- Register ApexGuru engine in EnginePluginsFactory
- Wire target-org through CliOverrides to engine config
- Add unit tests for flag parsing and config wiring

The flag value is passed to the ApexGuru engine via engine_overrides
config as target_org field, following the engine's config schema.
Add E2E tests verifying --target-org and -o shorthand are accepted
and parsed without errors. Tests use try-catch since ApexGuru may
fail in test environment without authenticated org.
Test stubs were missing getInsights and getEngineInsights methods
added to RunResults interface in core. Also disable lint warning
for target-org -o shorthand which is the correct convention.
@nikhil-mittal-165 nikhil-mittal-165 marked this pull request as ready for review June 16, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant