Code Analysis

Get code analysis for a branch

get

Retrieves code analysis results for a specific repository branch.

Three-state response pattern:

  • available: Analysis data exists and is returned in the data field

  • pending: No data exists; a new analysis has been triggered. Poll using the returned jobId

  • error: An error occurred (e.g., project not found)

Auto-trigger behavior:

  • If no analysis exists, automatically triggers a Windmill flow to run the analysis

  • Creates a daily schedule (3 AM UTC) for the project if one doesn't exist

Tools used: Salesforce Code Analyzer (PMD, ESLint, regex, retire-js, cpd)

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
branchstringRequired

Git branch name to get analysis for

Example: main
commitIdstringOptional

Specific commit SHA. If omitted, returns the latest analyzed commit.

Responses
chevron-right
200

Analysis data or pending/error status

application/json
statusstring · enumRequired

Response status indicating data availability

Example: availablePossible values:
jobIdstringOptional

Windmill job ID for tracking (present when status is "pending")

Example: 019b7251-ec8f-a661-2b2a-8d2699a64569
messagestringOptional

Human-readable status message or error description

Example: Analysis started. Job ID: 019b7251-ec8f-a661-2b2a-8d2699a64569. Schedule created.
get
/sfp/api/testreports/code-analysis

Force refresh code analysis

post

Triggers a new code analysis regardless of whether data already exists.

Behavior:

  • If branch is specified: Analyzes only that branch

  • If branch is omitted: Analyzes all branches configured in the project's configuration.branches (defaults to ["main"])

Returns: A pending response with the Windmill job ID to track progress.

Use cases:

  • Force re-analysis after code changes

  • Trigger analysis for all branches at once

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
branchstringOptional

Specific branch to analyze. If omitted, analyzes all configured branches.

Responses
chevron-right
200

Analysis refresh triggered

application/json
statusstring · enumRequired

Response status indicating data availability

Example: availablePossible values:
jobIdstringOptional

Windmill job ID for tracking (present when status is "pending")

Example: 019b7251-ec8f-a661-2b2a-8d2699a64569
messagestringOptional

Human-readable status message or error description

Example: Analysis started. Job ID: 019b7251-ec8f-a661-2b2a-8d2699a64569. Schedule created.
post
/sfp/api/testreports/code-analysis/refresh

Store code analysis results

post

Stores SARIF analysis results from an external source (typically Windmill flows).

Duplicate handling: If results already exist for the given commit, the request is ignored (same commit = same results).

Data processing:

  • Extracts summary metrics from SARIF (issues by severity, by rule, files affected)

  • Applies retention policy (keeps last 10 runs per branch)

Note: This endpoint is primarily used by Windmill flows, not direct API consumers.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
branchstringRequired

Git branch name

Example: main
commitIdstringRequired

Git commit SHA

Example: abc123def456789
analyzedAtstringRequired

Analysis timestamp in ISO 8601 format

Example: 2025-01-01T12:00:00.000Z
durationnumberRequired

Analysis duration in seconds

Example: 45
sarifobjectRequired

Raw SARIF 2.1.0 document from code analyzer

Example: {"version":"2.1.0","runs":[]}
Responses
post
/sfp/api/testreports/code-analysis/results

Get analysis history for a branch

get

Returns the last N analysis runs for a specific branch, ordered by analysis date (newest first).

Use cases:

  • Display trend charts

  • Compare analysis results over time

  • Track code quality improvements

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
branchstringRequired

Git branch name

Example: main
Query parameters
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
limitnumberOptional

Maximum number of results (default: 10, max: 100)

Example: 10
Responses
chevron-right
200

Analysis history for the branch

application/json
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
branchstringRequired

Git branch name that was analyzed

Example: main
commitIdstringRequired

Full Git commit SHA that was analyzed (used as document key)

Example: bfffb1da08589734f2781e3a4b5f4d4105efac72
analyzedAtstring · date-timeRequired

Timestamp when analysis was performed (ISO 8601 format)

Example: 2025-12-31T02:16:46.000Z
durationnumberRequired

Total analysis duration in seconds (clone + analyze + store)

Example: 43
sarifobjectOptional

Full SARIF 2.1.0 document (only included in detail views, omitted in lists)

get
/sfp/api/testreports/code-analysis/history/{branch}

Get branch dashboard with trends

get

Returns a comprehensive dashboard view for a specific branch including:

  • Latest analysis: Full analysis result with summary

  • History: Last 10 analysis runs (for trend charts)

  • Trends: Issue count trend direction (up/down/stable)

Trend calculation: Compares average issues in the last 3 runs vs previous 3 runs.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Path parameters
branchstringRequired

Git branch name

Example: main
Query parameters
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
Responses
chevron-right
200

Branch dashboard with latest analysis, history, and trends

application/json
repositoryIdentifierstringRequired

Repository identifier in org/repo format

Example: flxbl-io/sf-core
branchstringRequired

Git branch name

Example: main
get
/sfp/api/testreports/code-analysis/dashboard/{branch}

Last updated