Code Analysis
sfp server API reference for Code Analysis: 5 endpoints.
/sfp/api/testreports/code-analysisRetrieves code analysis results for a specific repository branch.
Three-state response pattern:
available: Analysis data exists and is returned in thedatafieldpending: No data exists; a new analysis has been triggered. Poll using the returnedjobIderror: An error occurred (e.g., project not found)
Auto-trigger behavior:
- If no analysis exists, automatically triggers a workflow 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)
Authorization
access-token In: header
Query Parameters
Repository identifier in org/repo format
Git branch name to get analysis for
Specific commit SHA. If omitted, returns the latest analyzed commit.
Response Body
application/json
curl -X GET "https://example.com/sfp/api/testreports/code-analysis?repositoryIdentifier=flxbl-io%2Fsf-core&branch=main"{ "status": "available", "data": { "repositoryIdentifier": "flxbl-io/sf-core", "branch": "main", "commitId": "bfffb1da08589734f2781e3a4b5f4d4105efac72", "analyzedAt": "2025-12-31T02:16:46.000Z", "duration": 43, "summary": { "totalIssues": 49, "issuesByLevel": { "error": 23, "warning": 26, "note": 0, "none": 0 }, "issuesByRule": [ { "ruleId": "ApexCRUDViolation", "ruleName": "Apex CRUD Violation", "count": 15, "level": "error" } ], "toolsUsed": [ { "name": "code-analyzer", "version": "5.0.0" } ], "filesAffected": 34, "analysisSuccessful": true }, "metadata": { "triggeredBy": "schedule", "scheduledRun": true, "tools": [ "code-analyzer" ] }, "sarif": {} }, "jobId": "019b7251-ec8f-a661-2b2a-8d2699a64569", "message": "Analysis started. Job ID: 019b7251-ec8f-a661-2b2a-8d2699a64569. Schedule created."}/sfp/api/testreports/code-analysis/refreshTriggers a new code analysis regardless of whether data already exists.
Behavior:
- If
branchis specified: Analyzes only that branch - If
branchis omitted: Analyzes all branches configured in the project'sconfiguration.branches(defaults to["main"])
Returns: A pending response with a task execution ID to track progress.
Use cases:
- Force re-analysis after code changes
- Trigger analysis for all branches at once
Authorization
access-token In: header
Query Parameters
Repository identifier in org/repo format
Specific branch to analyze. If omitted, analyzes all configured branches.
Response Body
application/json
curl -X POST "https://example.com/sfp/api/testreports/code-analysis/refresh?repositoryIdentifier=flxbl-io%2Fsf-core"{ "status": "available", "data": { "repositoryIdentifier": "flxbl-io/sf-core", "branch": "main", "commitId": "bfffb1da08589734f2781e3a4b5f4d4105efac72", "analyzedAt": "2025-12-31T02:16:46.000Z", "duration": 43, "summary": { "totalIssues": 49, "issuesByLevel": { "error": 23, "warning": 26, "note": 0, "none": 0 }, "issuesByRule": [ { "ruleId": "ApexCRUDViolation", "ruleName": "Apex CRUD Violation", "count": 15, "level": "error" } ], "toolsUsed": [ { "name": "code-analyzer", "version": "5.0.0" } ], "filesAffected": 34, "analysisSuccessful": true }, "metadata": { "triggeredBy": "schedule", "scheduledRun": true, "tools": [ "code-analyzer" ] }, "sarif": {} }, "jobId": "019b7251-ec8f-a661-2b2a-8d2699a64569", "message": "Analysis started. Job ID: 019b7251-ec8f-a661-2b2a-8d2699a64569. Schedule created."}/sfp/api/testreports/code-analysis/resultsStores SARIF analysis results from an external source (typically Hatchet workflows).
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 Hatchet workflows, not direct API consumers.
Authorization
access-token In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/sfp/api/testreports/code-analysis/results" \ -H "Content-Type: application/json" \ -d '{ "repositoryIdentifier": "flxbl-io/sf-core", "branch": "main", "commitId": "abc123def456789", "analyzedAt": "2025-01-01T12:00:00.000Z", "duration": 45, "sarif": { "version": "2.1.0", "runs": [] } }'{ "success": true}/sfp/api/testreports/code-analysis/history/{branch}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
Authorization
access-token In: header
Path Parameters
Git branch name
Query Parameters
Repository identifier in org/repo format
Maximum number of results (default: 10, max: 100)
Response Body
application/json
curl -X GET "https://example.com/sfp/api/testreports/code-analysis/history/main?repositoryIdentifier=flxbl-io%2Fsf-core"[ { "repositoryIdentifier": "flxbl-io/sf-core", "branch": "main", "commitId": "bfffb1da08589734f2781e3a4b5f4d4105efac72", "analyzedAt": "2025-12-31T02:16:46.000Z", "duration": 43, "summary": { "totalIssues": 49, "issuesByLevel": { "error": 23, "warning": 26, "note": 0, "none": 0 }, "issuesByRule": [ { "ruleId": "ApexCRUDViolation", "ruleName": "Apex CRUD Violation", "count": 15, "level": "error" } ], "toolsUsed": [ { "name": "code-analyzer", "version": "5.0.0" } ], "filesAffected": 34, "analysisSuccessful": true }, "metadata": { "triggeredBy": "schedule", "scheduledRun": true, "tools": [ "code-analyzer" ] }, "sarif": {} }]/sfp/api/testreports/code-analysis/dashboard/{branch}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.
Authorization
access-token In: header
Path Parameters
Git branch name
Query Parameters
Repository identifier in org/repo format
Response Body
application/json
curl -X GET "https://example.com/sfp/api/testreports/code-analysis/dashboard/main?repositoryIdentifier=flxbl-io%2Fsf-core"{ "repositoryIdentifier": "flxbl-io/sf-core", "branch": "main", "latestAnalysis": { "repositoryIdentifier": "flxbl-io/sf-core", "branch": "main", "commitId": "bfffb1da08589734f2781e3a4b5f4d4105efac72", "analyzedAt": "2025-12-31T02:16:46.000Z", "duration": 43, "summary": { "totalIssues": 49, "issuesByLevel": { "error": 23, "warning": 26, "note": 0, "none": 0 }, "issuesByRule": [ { "ruleId": "ApexCRUDViolation", "ruleName": "Apex CRUD Violation", "count": 15, "level": "error" } ], "toolsUsed": [ { "name": "code-analyzer", "version": "5.0.0" } ], "filesAffected": 34, "analysisSuccessful": true }, "metadata": { "triggeredBy": "schedule", "scheduledRun": true, "tools": [ "code-analyzer" ] }, "sarif": {} }, "history": [ { "commitId": "bfffb1da08589734", "analyzedAt": "2025-12-31T02:16:46.000Z", "totalIssues": 49, "errors": 23, "warnings": 26 } ], "trends": { "issuesTrend": "down" }}