JUnit XML output
vulkro-sf antipatterns --format junit writes a JUnit XML report: each finding is a <testcase> with a <failure>, so any CI that reads JUnit shows it as a failed test.
vulkro-sf antipatterns . --format junit > vulkro-sf-junit.xml
Shape
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="vulkro-sf.antipatterns" tests="1" failures="1" errors="0">
<properties>
<property name="vulkroSchemaVersion" value="1"/>
<property name="vulkroScannerName" value="vulkro-sf"/>
</properties>
<testcase classname="AP-001" name="AP-001 SOQL query inside a loop (./force-app/main/default/classes/LeadBatch.cls:4)">
<failure type="AP-001" message="A SOQL query executes inside a loop at line 4: ...">Move the SOQL query outside the loop. ...</failure>
</testcase>
</testsuite>
| Field | Content |
|---|---|
classname, failure type | The rule id, so CI groups findings per rule |
name | Rule id, title and file:line |
failure message | The finding detail, XML-escaped |
failure body | The remediation |
CI
GitLab CI:
vulkro-sf-antipatterns:
script:
- vulkro-sf antipatterns . --format junit > vulkro-sf-junit.xml
artifacts:
when: always
reports:
junit: vulkro-sf-junit.xml
Jenkins:
sh 'vulkro-sf antipatterns . --format junit > vulkro-sf-junit.xml || true'
junit testResults: 'vulkro-sf-junit.xml', allowEmptyResults: true
On GitHub Actions, write the file the same way and pass it to any JUnit test-report action with if: always().
Exit codes
0 no findings (tests="0"), 1 findings reported (or no licence), 2 error.
See also: Anti-patterns report, SARIF output